Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit e7585f3

Browse files
Merge pull request #297 from sandeep-deriv/sandeep/dapi-513/fix-auth-redirects
sandeep/dapi-513/fix auth and websocket url
2 parents ac72fd6 + 9148cab commit e7585f3

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,6 @@ npm-debug.log*
2222
yarn-debug.log*
2323
yarn-error.log*
2424

25-
.idea
25+
.idea
26+
27+
.vscode/settings.json

src/features/Endpoint/Endpoint.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { useForm } from 'react-hook-form';
33
import { Button, Text } from '@deriv/ui';
44
import { getAppId } from '@site/src/utils';
5-
import { OAUTH_URL } from '@site/src/utils/constants';
5+
import { DEFAULT_WS_SERVER } from '@site/src/utils/constants';
66
import styles from './Endpoint.module.scss';
77

88
interface IEndpointFormValues {
@@ -12,7 +12,7 @@ interface IEndpointFormValues {
1212
const EndPoint = () => {
1313
const default_endpoint = {
1414
app_id: getAppId(),
15-
server_url: OAUTH_URL,
15+
server_url: DEFAULT_WS_SERVER,
1616
};
1717

1818
const {

src/features/Endpoint/__tests__/Endpoint.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
22
import React from 'react';
33
import EndPoint from '../Endpoint';
44
import userEvent from '@testing-library/user-event';
5+
import { DEFAULT_WS_SERVER } from '@site/src/utils/constants';
56

67
describe('Endpoint', () => {
78
beforeEach(() => {
@@ -23,7 +24,7 @@ describe('Endpoint', () => {
2324
it('should have default values in input fields', () => {
2425
const server = screen.getByPlaceholderText('e.g. ws.derivws.com');
2526
const app_id = screen.getByPlaceholderText('e.g. 9999');
26-
expect(server).toHaveValue('oauth.deriv.com');
27+
expect(server).toHaveValue(DEFAULT_WS_SERVER);
2728

2829
expect(app_id).toHaveValue('35074');
2930
});

src/utils/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,13 @@ export const getServerConfig = () => {
143143
if (isBrowser) {
144144
const config_server_url = localStorage.getItem('config.server_url');
145145
const config_app_id = localStorage.getItem('config.app_id');
146+
const is_qa_server = config_server_url?.toLowerCase().includes('qa');
147+
const oauth = is_qa_server ? config_server_url : OAUTH_URL;
146148

147149
return {
148150
serverUrl: config_server_url ?? DEFAULT_WS_SERVER,
149151
appId: config_app_id ?? getAppId(),
150-
oauth: config_server_url ?? OAUTH_URL,
152+
oauth,
151153
};
152154
} else {
153155
return {

0 commit comments

Comments
 (0)