-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support new middleware cookies api #544
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the preview is broken
https://nextra-theme-docs-dev-git-fork-huozhi-fix-next-middleware-api.vercel.sh/zh-CN
I think the reason is that
nextra/packages/nextra/src/locales.ts
Line 16 in 6d5c85e
const fullUrl = nextUrl.toString() |
fullUrl
is different between next 12.1
and next 12.2
When user access https://swr.vercel.app/zh-CN
-
12.1
fullUrl
would behttps://swr.vercel.app/zh-CN/
-
12.2
fullUrl
would behttps://swr.vercel.app/zh-CN
It doesn't have trailing slash
test against actual api
* Support new middleware cookies api * update example * handle slashes * fix locale rewrites * extract locale for w/o trailing slash * fallback / * extract locale correctly * fix lock * update test snapshots * fix non index pages i18n * test: add locale middleware test * test against actual api test against actual api * fix locale Co-authored-by: Yixuan Xu <yixuanxu94@outlook.com>
x-ref: vercel/swr-site#307 (comment)
rewrite the lcoale extracting from url logic, previously the pathname can be
/
, then the url with host removed can bezh-CN
orzh-CN/
in with next version (12.2 vs 12.1). We'd better to find the first slash and get extract the locale from itThanks @promer94 for helping with setting up locale tests