Skip to content

Commit

Permalink
temp(soc): redirect all soc requests to support.xd.com
Browse files Browse the repository at this point in the history
  • Loading branch information
leeyeh committed Oct 24, 2023
1 parent 2307bb8 commit 66c9c2e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions in-app/v1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
</head>
<body>
<div id="root"></div>
<script>
if (window.location.host !== 'support.xd.com', window.location.pathname.startsWith('/in-app/v1/products/soc')) {
const newUrl = new URL('https://support.xd.com');
newUrl.pathname = window.location.pathname;
newUrl.search = window.location.search;
newUrl.hash = window.location.hash;
window.location.replace(newUrl.toString());
}
</script>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
14 changes: 14 additions & 0 deletions next/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
13 changes: 13 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 66c9c2e

Please sign in to comment.