From 2e2a5897b8a52eab404c87ecf71953d3a75c7ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jovan=20Kruni=C4=87?= Date: Wed, 23 Mar 2022 21:52:27 +0100 Subject: [PATCH] refactor: use current location for auth unless production --- package-lock.json | 2 +- .../modules/auth/factories/auth.factory.ts | 21 +++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fc95b4f5..8cb63c83 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@openstapps/app", - "version": "0.0.1", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/app/modules/auth/factories/auth.factory.ts b/src/app/modules/auth/factories/auth.factory.ts index a74470cd..6bb4ad75 100644 --- a/src/app/modules/auth/factories/auth.factory.ts +++ b/src/app/modules/auth/factories/auth.factory.ts @@ -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}`; }