From 66c9c2e6bed73f14b78ddd23904d442449990d9f Mon Sep 17 00:00:00 2001 From: Lee Yeh Date: Tue, 24 Oct 2023 18:00:35 +0000 Subject: [PATCH] temp(soc): redirect all soc requests to support.xd.com --- in-app/v1/index.html | 9 +++++++++ next/api/src/index.ts | 14 ++++++++++++++ server.js | 13 +++++++++++++ 3 files changed, 36 insertions(+) diff --git a/in-app/v1/index.html b/in-app/v1/index.html index e7410f6b5..cfcaed252 100644 --- a/in-app/v1/index.html +++ b/in-app/v1/index.html @@ -12,6 +12,15 @@
+ diff --git a/next/api/src/index.ts b/next/api/src/index.ts index 0e33b4350..2fcdf264b 100644 --- a/next/api/src/index.ts +++ b/next/api/src/index.ts @@ -142,6 +142,20 @@ app.use( }) ); +app.use((ctx, next) => { + if ( + ctx.hostname !== 'support.xd.com' && + (ctx.query.product === 'soc' ) + ) { + const url = new URL(ctx.url, 'https://support.xd.com') + ctx.response.status = 307; + ctx.response.set('Location', url.toString()); + ctx.response.body = ''; + return + } + next() +}) + app.use(api.routes()); app.use(integrationRouter.routes()); diff --git a/server.js b/server.js index e8683de7d..8447e59b6 100644 --- a/server.js +++ b/server.js @@ -20,6 +20,19 @@ const config = require('./config') const { clientGlobalVars } = require('./clientGlobalVar') const app = express() + +// app.all('*', (req, res, next) => { +// if ( +// req.hostname !== 'support.xd.com' && +// (req.path.startsWith('/in-app/v1/products/soc')) +// ) { +// const url = new URL(req.url, 'https://support.xd.com') +// res.redirect(307, url.toString()) +// return +// } +// next() +// }) + const apiRouter = require('./api') const { Sentry, Tracing } = require('./next/api/dist/sentry')