-
Notifications
You must be signed in to change notification settings - Fork 155
fix: normalize the rawPath without locale before attempting to asserting the 404 page #448
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
fix: normalize the rawPath without locale before attempting to asserting the 404 page #448
Conversation
🦋 Changeset detectedLatest commit: 8bb1728 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Thanks! We might want to add i18n to the e2e app to better test these scenarios.
I've updated the examples/pages-routes project to include some i18n config. I looked at the current e2e and they would already cover this bug since they assert the data json calls are resolving. Would that be sufficient enough? |
Thanks for adding the configs. I think it'll be useful to test the actual internationalization of the e2e apps to, that is, to add |
Hmm, looking at the example I'm not sure it would work seeing that the middleware takes care of all the i18n stuff with the app router. This means that I wouldn't know the i18n configuration to start with so my new "code" would never be executed 🤔 TBH not using the app router at all atm, we stick with good old Pages 🤷 |
It shouldn't be necessary to change anything for app dir, the middleware rewrites should already be applied at this point |
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.
There is a few issues with it.
Ideally we should also handle the locale:true|false
options in Next config rewrite/redirect
// Add the locale prefix to the regex so we correctly match the rawPath | ||
const optionalLocalePrefixRegex = !!RoutesManifest.locales.length | ||
? `^/(?:${RoutesManifest.locales.map((locale) => `${locale}/?`).join("|")})?` | ||
: null; |
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.
This make pnpm run build
fail for me, in case people don't have i18n it should be the same so ^/
@@ -22,12 +22,17 @@ export interface MiddlewareOutputEvent { | |||
origin: Origin | false; | |||
} | |||
|
|||
// Add the locale prefix to the regex so we correctly match the rawPath | |||
const optionalLocalePrefixRegex = !!RoutesManifest.locales.length | |||
? `^/(?:${RoutesManifest.locales.map((locale) => `${locale}/?`).join("|")})?` |
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.
This cause an issue with 3 e2e test because of this, it should also include the default case (i.e. with no locales prefix)
For the next data test it is because of this https://github.com/sst/open-next/blob/9d632d1bd5c3a8d7e7bbd13ae9daaca68da9284e/packages/tests-e2e/tests/pagesRouter/data.test.ts#L13 It ends now with en.json
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.
What would be the best approach here? Create a new pages app with i18n + additional e2e tests? 🤔 . It's expected that in this case it's en.json
instead of index.json
(but only if you have i18n settings).
It's a bit of a mess (on Next.js side)
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.
In a perfect world, yeah we should do something like that, but honestly just testing with en.json
is probably enough
No description provided.