Redirecting to a holding page during development - middleware? #44954
-
Hello, I'm currently developing a large site with NextJS, and have the site deployed on Vercel. I would like to move the over to our 'real' domain name instead of the Vercel domain, but before I do that I wonder if it's possible to automatically show a holding page when the live site is viewed while the site is in development? I've looked into it and it seems this is something I should be using middleware for - is this correct or indeed possible? Ideally I would like to redirect to, let's say, /coming-soon if the .env variable is dev or something, but still grant access to certain ip addresses. |
Beta Was this translation helpful? Give feedback.
Replies: 2 suggested answers
{{editor}}'s edit
{{editor}}'s edit
-
Ah, I should have checked the examples folder first. I've got a basic version working now with the following code:
What I would really like to do is enable just myself to view the site without the redirect, while everyone else gets directed to the coming-soon page. I'm trying to do it like this, whereby if the ip address in the headers is not my public ip address, do the redirect, else just show the normal page:
However, it's still redirects me to the coming-soon page. Does anyone have any ideas? |
Beta Was this translation helpful? Give feedback.
-
Ok I figured it out by reading the Middleware API docs
|
Beta Was this translation helpful? Give feedback.
Ok I figured it out by reading the Middleware API docs😁