Skip to content

Commit

Permalink
feat: added logic to manually set server_url and app_id for staging-p2p
Browse files Browse the repository at this point in the history
  • Loading branch information
shayan-deriv committed Jun 14, 2024
1 parent f05a31b commit 232f914
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions src/constants/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LocalStorageConstants, LocalStorageUtils, URLConstants, URLUtils } from '@deriv-com/utils';
import { AppIDConstants, LocalStorageConstants, LocalStorageUtils, URLConstants, URLUtils } from '@deriv-com/utils';

export const BUY_SELL_URL = '/buy-sell';
export const ORDERS_URL = '/orders';
Expand All @@ -13,9 +13,32 @@ export const DERIV_COM = URLConstants.derivComProduction;
export const HELP_CENTRE = `${URLConstants.derivComProduction}/help-centre/`;
export const RESPONSIBLE = `${URLConstants.derivComProduction}/responsible/`;

const SocketURL = {
'p2p.deriv.com': 'blue.derivws.com',
'staging-p2p.deriv.com': 'red.derivws.com',
};

export const getOauthUrl = () => {
const appId = LocalStorageUtils.getValue(LocalStorageConstants.configAppId);
const hostname = window.location.hostname;

// since we don't have official app_id for staging,
// we will use the red server with app_id=62019 for the staging-p2p.deriv.com for now
// to fix the login issue
if (hostname === 'staging-p2p.deriv.com') {
localStorage.setItem(
LocalStorageConstants.configServerURL.toString(),
SocketURL[hostname as keyof typeof SocketURL]
);
localStorage.setItem(
LocalStorageConstants.configAppId,
AppIDConstants.domainAppId[hostname as keyof typeof AppIDConstants.domainAppId]
);
}

const serverUrl = localStorage.getItem(LocalStorageConstants.configServerURL.toString());

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

const oauthUrl =
appId && serverUrl
? `https://${serverUrl}/oauth2/authorize?app_id=${appId}&l=EN&&brand=deriv`
Expand Down

0 comments on commit 232f914

Please sign in to comment.