Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: i18n doc needs to be updated for to use with url absolute & nextUrl clone #35273

Closed
santyas opened this issue Mar 12, 2022 · 2 comments · Fixed by #35874
Closed

Docs: i18n doc needs to be updated for to use with url absolute & nextUrl clone #35273

santyas opened this issue Mar 12, 2022 · 2 comments · Fixed by #35874
Assignees

Comments

@santyas
Copy link

santyas commented Mar 12, 2022

What is the improvement or update you wish to see?

i18n: docs example is deprecated:
at _middleware: https://nextjs.org/docs/advanced-features/i18n-routing#prefixing-the-default-locale

Now with 12.1, nextjs suggest to use clone() of nextUrl and replace relative URLs by absolute.

"URLs is malformed. Please use only absolute URLs"
https://nextjs.org/docs/messages/middleware-relative-urls

Is there any context that might help us understand?

Can't use Nextjs example code at docs with url relatives:

const res = redirect(`/${ localeOrGeoCookie }${ nextUrl.pathname }`) // without clone it

I think to use clone will help:

const url = request.nextUrl.clone()
const res = NextResponse.redirect( `${url.origin}/${localeOrGeoCookie}` )
res.cookie('GEO_COUNTRY', country) // optional, I need to store geo country name
return res

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/advanced-features/i18n-routing#prefixing-the-default-locale

@santyas santyas added the Documentation Related to Next.js' official documentation. label Mar 12, 2022
@kristojorg
Copy link
Contributor

The docs still need to mention nextUrl.clone() and describe when it should be used. I am pretty unclear on this and have run in to bugs in production where nextUrl is somehow an empty object. Looks like it was because I didn't clone it

@molebox molebox added area: documentation and removed Documentation Related to Next.js' official documentation. labels Mar 29, 2022
@kodiakhq kodiakhq bot closed this as completed in #35874 Apr 6, 2022
kodiakhq bot pushed a commit that referenced this issue Apr 6, 2022
## Bug
fixes #35273

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
colinhacks pushed a commit to colinhacks/next.js that referenced this issue Apr 14, 2022
## Bug
fixes vercel#35273

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
@github-actions
Copy link
Contributor

github-actions bot commented May 7, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2022
pavleadev pushed a commit to pavleadev/next.js that referenced this issue Mar 29, 2023
## Bug
fixes vercel/next.js#35273

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`


## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants