diff --git a/themes/gatsby-theme-deriv/gatsby-browser.js b/themes/gatsby-theme-deriv/gatsby-browser.js index 1129510fd23..98cf5624e8d 100644 --- a/themes/gatsby-theme-deriv/gatsby-browser.js +++ b/themes/gatsby-theme-deriv/gatsby-browser.js @@ -162,6 +162,22 @@ export const onRouteUpdate = ({ location }) => { const client_information = getClientInformation(domain) const is_logged_in = !!client_information + const path = location.pathname; + + if (path === '/mn') { + navigate('/', { replace: true }); + } else if (path.startsWith('/mn/')) { + const newPath = path.replace(/^\/mn/, ''); + navigate(newPath || '/', { replace: true }); + } + + if (path === '/km') { + navigate('/', { replace: true }); + } else if (path.startsWith('/km/')) { + const newPath = path.replace(/^\/km/, ''); + navigate(newPath || '/', { replace: true }); + } + // wrap inside a timeout to ensure the title has properly been changed setTimeout(() => { const eventName = 'page_load' diff --git a/themes/gatsby-theme-deriv/gatsby-node.js b/themes/gatsby-theme-deriv/gatsby-node.js index 1d3f74a999a..4c563623f05 100644 --- a/themes/gatsby-theme-deriv/gatsby-node.js +++ b/themes/gatsby-theme-deriv/gatsby-node.js @@ -250,19 +250,6 @@ const BuildPage = (page, actions, region) => { redirectInBrowser: true, isPermanent: true, }) - const mn_path = `/mn${localized_path.slice(0, -1)}` - createRedirect({ - fromPath: mn_path, - toPath: localized_path, - redirectInBrowser: true, - isPermanent: true, - }) - createRedirect({ - fromPath: `${mn_path}/`, - toPath: localized_path, - redirectInBrowser: true, - isPermanent: true, - }) } if (is_responsible_trading) {