I config my my next.config.js to redirect url if the query param fbclid or the header referer is present.
My Next.js site redirects correctly on localhost and vercel, but doesn’t redirect at all if deployed on Netlify.
I do not have a netlify.toml in the root dir or _redirects in public folder.
Do I miss something, or Netlify Next.js Runtime having a bug at the moment?
Here’s the same site deployed on Vercel. with all the redirections work correctly.
You can test it by appending ?fbclid=anyvalue to a post url or post the post url on facebook and click on.
Here are my next.config.js redirects.
Thanks for your quick response.
Yes, I did read the guide. My redirections need to rely on whether the referer header is present, so I think netlify.toml and _redirects are out of the options. Need to use next.config.js redirects.
The netlify.toml redirect has a conditions option, but only supports for Country, Role, Cookie, therefore I don’t think I can use it.
Thanks. I did read the thread. It seems the user was using _redirects file but did not put it in the public folder, so the redirection didn’t work.
In contrast to my issue, I’m not using netlify.toml or _redirects file (cause these things don’t support conditional redirection based on headers).
Instead, I’m using next.config.js, which is supposed to work under the recent Netlify Nextjs Runtime. But it doesn’t. My deployment on Vercel worked out of the box. Wonder whether I missed something on Netlify or there’s currently a bug with Netlify Nextjs Runtime.
Here’s the same site deployed on Vercel. with all the redirections work correctly.
You can test it by appending ?fbclid=anyvalue to a post url or post the post url on facebook and click on.
Steps to reproduce
I apologize, but the issue can’t be reproduced consistently. It happens intermittently. Sometimes it redirects correctly, the other times it doesn’t.
Example (if the below post url redirection worked at the time you try, please use other post urls): https://roaring-empanada-f826a3.netlify.app/posts/expedita-aut-autem-ab-repellendus?fbclid=anyvalue
Expected behaviour: since the link includes a fbclid query param, it should be redirected to https://swiftydragon.com/posts/expedita-aut-autem-ab-repellendus?fbclid=anyvalue
Sorry to be rude, but there are many issues with Nextjs on Netlify. Should just use Vercel instead. Deployments on Vercel work out of the box.
Also, the email support is nonexistent despite being on Pro plan. I did send an email request but there’s no response.
@ducbao414 Since Vercel create Next I think you’ll find that Netlify will always be playing a bit of catch up with it.
It may even be part of the reason why Netlify have acquired Gatsby, whereby they could cause the same dynamic with their competitors.
Support wise the last I heard from Netlify they consider the non-enterprise plans to be largely self-service “hobbyist” plans, which I posted about here:
Thanks for the info.
Been using DigitalOcean, Vultr, and CloudfFlare for years so I completely understand the part about self-serving.
I’ve just found it’s kind of misleading that Netlify includes the ‘email support’ feature as a selling point for Pro plan compared with the free plan, when in reality, there’s no response time guaranteed. It seems like an unscrupulous selling tactic.
Grateful for your help. Without valued community members like you, I would ditch Netlify on Day 1.
As confirmed with the devs, this is currently not possible. This is because Next.js ISR uses Netlify On Demand Builders under-the-hood and they don’t provide access to Query Parameters or Request Headers.
An alternative would be to use Next.js Middleware for this, as that runs on Netlify Edge Functions. You can also use Edge Functions directly, by the way, but if you wish to keep your app in the Next.js context, middleware would be the best option.