Hi all,
I want to use the NEXT_LOCALE cookie to redirect the corresponded language path automatically.
The functionality is described as the below link.
It can not work correctly on Netlify.
It works fine on Vercel.
https://sf1.vercel.app/
You can test the functionality by changing the language selector.
Test case1:
- Choose the Traditional Chinese(zh_TW) 中文(繁體).
- Go to the root URL /.
- It should show the Traditional Chinese Path: /zh-TW.
- The message above the selector will show ‘我是一則訊息 (繁中)’
Test case2:
- Choose the Simple Chinese(zh-CN).
- Go to the root URL /.
- It should show the Simple Chinese Path: /zh-CN.
- The message above the selector will show ‘我是一则讯息 (简中)’
Test case3:
- Choose the English.
- Go to the root URL /.
- It should show the Englis (Default Language) Path: /
- The message above the selector will show ‘am a message (English)’
Thank you.
Hi @antai0926,
Netlify uses its own nf_lang
cookie and the redirects can be setup like explained here: Redirect options | Netlify Docs
1 Like
Hi @hrishikesh
I see. Thanks for your help.
Hi @hrishikesh ,
I install the netlify-cli and use netlify dev command to run local server to test this case.
It works fine that I use NEXT_LOCALE (not nf_lang) in the netlify dev server in the local machine.
When I deploy it to the Netlify platform, it cannot work fine.
I want the development environment as the same as the Netlify platform, so I install the netlify cli to run the netlify dev.
How can I do that let my development environment as the same as the Netlify platform?
That I can find the problem in my local environment immediately not till deploying my project to Netlify platform.
Thank you.
Hi @antai0926,
The problem is that, when you use Netlify CLI, it’s proxying the requests to your SSG’s development server, in your case NextJS’ development server. That server is probably configured to handle NEXT_LOCALE
cookie and that’s what’s handling the redirect too.
However, in the production environment, there’s no NextJS development server, thus it won’t work in production. nf_lang
, however would work in both environments.
1 Like