Capacitor redirect URL issue

I have an auth workflow which opens a browser, then redirects back to the app to finish the login. This works well when opening a browser window outside the app, and using a custom URL scheme to redirect back to the app.

I’d like to do this with an in-browser app. Unfortunately the browser window hangs and doesn’t redirect back to the app. I am using the server.allowNavigation setting to get Capacitor to open the browser in-app.

Should a custom URL redirect back to the app when opened in-app? Or does an in-app URL need a different URL to get back to the main app window?

1 Like

I figured this out. I realized that my problem was the unexpected way to import the Capacitor Browser plugin. Once I imported like the Docs said, the in-app browser window worked great, using a custom URL scheme to redirect back to the app. I also removed these URLs from the allowNavigation setting (as in my case they are external and not controlled by us).

import { Plugins } from '@capacitor/core';    
const { Browser } = Plugins;
...
await Browser.open({ url: 'http://capacitorjs.com/' });
1 Like