Skip to content

Commit 38602b6

Browse files
authored
Merge pull request #143 from shayan-deriv/master
fix: fixed endpoint can't be set manually
2 parents b2e10c0 + b6e8edb commit 38602b6

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/constants/url.ts

+5-3
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ export const getOauthUrl = () => {
2222
const origin = window.location.origin;
2323
const hostname = window.location.hostname;
2424

25+
const existingAppId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId);
26+
const existingServerUrl = LocalStorageUtils.getValue(LocalStorageConstants.configServerURL);
2527
// since we don't have official app_id for staging,
2628
// we will use the red server with app_id=62019 for the staging-p2p.deriv.com for now
2729
// to fix the login issue
28-
if (origin === URLConstants.derivP2pStaging) {
30+
if (!/localhost/.test(origin) && (!existingAppId || !existingServerUrl)) {
2931
localStorage.setItem(
3032
LocalStorageConstants.configServerURL.toString(),
3133
SocketURL[origin as keyof typeof SocketURL]
@@ -36,8 +38,8 @@ export const getOauthUrl = () => {
3638
);
3739
}
3840

39-
const storedServerUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString());
40-
const serverUrl = /qa/.test(storedServerUrl || '') ? storedServerUrl : 'oauth.deriv.com';
41+
const storedServerUrl = LocalStorageUtils.getValue(LocalStorageConstants.configServerURL);
42+
const serverUrl = /qa/.test(String(storedServerUrl)) ? storedServerUrl : 'oauth.deriv.com';
4143

4244
const appId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId);
4345

0 commit comments

Comments
 (0)