From d8e6c18ea720ea126f3db0b84752217a0bd6be6a Mon Sep 17 00:00:00 2001 From: shayan khaleghparast Date: Thu, 13 Jun 2024 16:43:53 +0800 Subject: [PATCH] fix: fixed multiple connection issue --- public/localstorage-sync.html | 2 ++ src/components/DerivIframe/DerivIframe.tsx | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/localstorage-sync.html b/public/localstorage-sync.html index 331c3125..bb2cd8e7 100644 --- a/public/localstorage-sync.html +++ b/public/localstorage-sync.html @@ -23,12 +23,14 @@ switch (message.data.key) { case 'active_loginid': { if (localStorage.getItem(message.data.key) !== message.data.value) { + console.log('setting p2p localStorage for active_loginid'); localStorage.setItem(message.data.key, message.data.value); } break; } case 'client.accounts': { if (localStorage.getItem(message.data.key) !== message.data.value) { + console.log('setting p2p localStorage for client.accounts'); localStorage.setItem(message.data.key, message.data.value); } break; diff --git a/src/components/DerivIframe/DerivIframe.tsx b/src/components/DerivIframe/DerivIframe.tsx index 8b56f3f1..541967a6 100644 --- a/src/components/DerivIframe/DerivIframe.tsx +++ b/src/components/DerivIframe/DerivIframe.tsx @@ -2,10 +2,12 @@ import { URLConstants } from '@deriv-com/utils'; const DerivIframe = () => { const getAllowedLocalStorageOrigin = () => { - if (/^staging-p2p\.deriv\.com$/i.test(window.location.hostname)) { + const hostName = window.location.hostname; + if (/^staging-p2p\.deriv\.com$/i.test(hostName)) { return URLConstants.derivP2pStaging; + } else if (/^localhost$/i.test(hostName)) { + return window.location.origin; } - return URLConstants.derivP2pProduction; };