-
Notifications
You must be signed in to change notification settings - Fork 381
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
Locale not included in withPageAuthRequired
redirect
#353
Comments
Thanks for reporting @davemaier - will investigate |
looks like we need to add Since i18n routing can be Domain Routing as well as sub path, prefixing the locale to the path wont work for all cases. We may have to use I'm not sure what the equivalent is going to be for the SSR one, will raise some work internally to investigate |
This has been fixed for CSR For SSR export const getServerSideProps = (ctx) => {
return withPageAuthRequired({ returnTo: `${baseUrl}/${locale}${ctx.req.url}` })(ctx);
}; |
Closing this, feel free to ping me if you'd like me to reopen |
Describe the problem
I'm using internationalized routing and if I wrap a page in the
withPageAuthRequired
HOC, the locale isn't included in the redirect. This leads to the problem that if a user enters the page, selects a language (or a language is determined based on the browser locale), visits a protected page and fills the login form, she gets redirected to the correct page, but with the default locale.For example
/de/events/
becomes/events
after redirect.What was the expected behavior?
I expect that after login, the user gets redirected to the page with the locale she was using the website before.
Reproduction
Setup a website that uses internationalized routing and wrap some page in
withPageAuthRequired
HOC. Then visit the page with some locale that isn't the default locale. After login, you will be directed to the page with the default locale.Environment
The problem seems to be in
with-page-auth-required.tsx
where the redirect url is built as follows:returnTo = `${router.basePath ?? ''}${router.asPath}`
.I think this should be changed to something like this:
returnTo = `${router.basePath ? `${router.basePath}/` : ''}${router.locale}${router.asPath}`
This issue is closely related to #351
The text was updated successfully, but these errors were encountered: