refactor: use current location for auth unless production

This commit is contained in:
Jovan Krunić
2022-03-23 21:52:27 +01:00
parent 0479e7cdc3
commit 2e2a5897b8
2 changed files with 18 additions and 5 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@openstapps/app",
"version": "0.0.1",
"version": "2.0.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -116,8 +116,21 @@ function getEndpointsConfig(
* Return a URL of the app, depending on the platform where it is running
*/
function getRedirectUrl(routePath: string): string {
const appSchema = Capacitor.isNativePlatform()
? environment.custom_url_scheme
: 'https';
return `${appSchema}://${environment.app_host}/${routePath}`;
let appHost: string;
let appSchema: string;
if (environment.production) {
appSchema = Capacitor.isNativePlatform()
? environment.custom_url_scheme
: 'https';
appHost = environment.app_host;
} else {
appSchema = Capacitor.isNativePlatform()
? environment.custom_url_scheme
: window.location.protocol.split(':')[0];
appHost = Capacitor.isNativePlatform()
? environment.app_host
: window.location.host;
}
return `${appSchema}://${appHost}/${routePath}`;
}