Skip to content

Commit

Permalink
feat: conditionally prevent redirect to VERCEL_URL
Browse files Browse the repository at this point in the history
- redirect prevented if env.DISABLE_VERCEL_REDIRECT is true
  • Loading branch information
mohitb35 committed Jan 12, 2024
1 parent 057c639 commit 5bbb787
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const nextConfig = {
stripPrefix: ["webpack://_N_E/"],
urlPrefix: `~${basePath}/_next`,
release: COMMIT_SHA,
}),
})
);
}
return config;
Expand All @@ -117,6 +117,7 @@ const nextConfig = {
TRACKING_KEY: process.env.TRACKING_KEY,
ENABLE_GOOGLE_PAY: process.env.ENABLE_GOOGLE_PAY,
ENABLE_APPLE_PAY: process.env.ENABLE_APPLE_PAY,
DISABLE_VERCEL_REDIRECT: process.env.DISABLE_VERCEL_REDIRECT,
},
trailingSlash: false,
reactStrictMode: true,
Expand Down
5 changes: 4 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ function MyApp({
process.env.VERCEL_URL &&
typeof window !== "undefined"
) {
if (process.env.VERCEL_URL !== window.location.hostname) {
if (
process.env.VERCEL_URL !== window.location.hostname &&
process.env.DISABLE_VERCEL_REDIRECT !== "true"
) {
router.replace(`https://${process.env.VERCEL_URL}`);
}
}
Expand Down

0 comments on commit 5bbb787

Please sign in to comment.