Find Mobile Local Web Server Port


Hi there, I built an app that utilizes Google oAuth to authenticate, however, I am having a problem finding the redirect URL that I should use.

I found this passage on Meteor’s official documentation, however, it does not specify how can I find the port number, and I am having trouble determining it.

What port will your app be served from?
While Meteor uses a built-in request interception mechanism on Android, supporting WKWebView on iOS requires running a real embedded web server instead. That means the local web server needs a port to bind to, and we can’t simply use a fixed port because that might lead to conflicts when running multiple Meteor Cordova apps on the same device. The easiest solution may seem to use a randomized port, but this has a serious drawback: if the port changes each time you run the app, web features that depend on the origin (like caching, localStorage, IndexedDB) won’t persist between runs, and you also wouldn’t be able to specify a stable OAuth redirect URL. So instead we now pick a port from a predetermined range (12000-13000), calculated based on the appId, a unique identifier that is part of every Meteor project. That ensures the same app will always use the same port, but it hopefully avoids collisions between apps as much as possible. (There is still a theoretical possibility of the selected port being in use. Currently, starting the local server will fail in that case.)

Can someone tell me how to determine the port number I should send the redirect back to? Thank you so much for the help.