Skip to content

Commit 13b6710

Browse files
Merge pull request #133 from shayan-deriv/shayan/FEQ-2378/set-default-app-id-and-server-url-for-staging-p2p
feat: added logic to manually set server_url and app_id for staging-p2p
2 parents fe01d35 + 56a3167 commit 13b6710

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/constants/url.ts

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LocalStorageConstants, LocalStorageUtils, URLConstants, URLUtils } from '@deriv-com/utils';
1+
import { AppIDConstants, LocalStorageConstants, LocalStorageUtils, URLConstants, URLUtils } from '@deriv-com/utils';
22

33
export const BUY_SELL_URL = '/buy-sell';
44
export const ORDERS_URL = '/orders';
@@ -13,9 +13,33 @@ export const DERIV_COM = URLConstants.derivComProduction;
1313
export const HELP_CENTRE = `${URLConstants.derivComProduction}/help-centre/`;
1414
export const RESPONSIBLE = `${URLConstants.derivComProduction}/responsible/`;
1515

16+
const SocketURL = {
17+
[URLConstants.derivP2pProduction]: 'blue.derivws.com',
18+
[URLConstants.derivP2pStaging]: 'red.derivws.com',
19+
};
20+
1621
export const getOauthUrl = () => {
22+
const hostname = window.location.origin;
23+
24+
// since we don't have official app_id for staging,
25+
// we will use the red server with app_id=62019 for the staging-p2p.deriv.com for now
26+
// to fix the login issue
27+
if (hostname === URLConstants.derivP2pStaging) {
28+
localStorage.setItem(
29+
LocalStorageConstants.configServerURL.toString(),
30+
SocketURL[hostname as keyof typeof SocketURL]
31+
);
32+
localStorage.setItem(
33+
LocalStorageConstants.configAppId,
34+
AppIDConstants.domainAppId[hostname as keyof typeof AppIDConstants.domainAppId]
35+
);
36+
}
37+
38+
const storedServerUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString());
39+
const serverUrl = /qa/.test(storedServerUrl || '') ? storedServerUrl : 'oauth.deriv.com';
40+
1741
const appId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId);
18-
const serverUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString());
42+
1943
const oauthUrl =
2044
appId && serverUrl
2145
? `https://${serverUrl}/oauth2/authorize?app_id=${appId}&l=EN&&brand=deriv`

0 commit comments

Comments
 (0)