-
Notifications
You must be signed in to change notification settings - Fork 2.9k
[next] ensure app router 404 page is still included in functions when using pages i18n #13222
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
Conversation
🦋 Changeset detectedLatest commit: 28ac2a3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
04cb49b
to
46d3c34
Compare
09919dd
to
6b435ae
Compare
3a13dba
to
8aa7fd2
Compare
async function validateSlug(slug: string[]) { | ||
try { | ||
const isValidPath = | ||
slug.length === 1 && (slug[0] === 'about' || slug[0] === 'contact'); |
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.
readability wise: "contact" seems not used, maybe we can give an easier testing slug isValidPath = slug.length === 1 && slug[0] === "valid"
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## vercel@41.6.0 ### Minor Changes - `vercel dev` will now automatically refresh the `VERCEL_OIDC_TOKEN` environment ([#13226](#13226)) variable and restart the development server before it expires. ### Patch Changes - fix(auth): fix rendering fallback verification link ([#13232](#13232)) - Updated dependencies \[[`b696b2dc8e6a2bb6c9dc1c6ce99cddf375b61559`](b696b2d), [`a640944c6e2c69afab5b7f03080d8363ef4bcf5b`](a640944), [`f0730d4b77f158c75b119544ee8756a609f22fdf`](f0730d4)]: - @vercel/next@4.7.7 ## @vercel/firewall@0.1.7 ### Patch Changes - fix(readme): updated link to documentation about the SDK ([#13210](#13210)) ## @vercel/next@4.7.7 ### Patch Changes - Fix for rewrite headers that ensures that we don't check post-non rewrite operations (like adding headers). ([#13229](#13229)) - [next] ensure app router 404 page is still included in functions when using pages i18n ([#13222](#13222)) - [next] improve error message for "No Next.js version" ([#13239](#13239)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
…config (#77905) When using both pages & app routers, during `next dev` and `next start`, if a function triggers a 404 error, we serve the app router not found page rather than the pages router one. When paired with the `i18n` configuration in `next.config`, the Next.js builder ignores the app router 404 and bundles the localized pages router 404 pages with the deployed functions. This leads to a 500 error, and is fixed in vercel/vercel#13222 However, to match the dev/start handling, we also need to update the `pages-manifest` so the builder knows to resolve `/404.html` and not the pages router variant when deployed. Fixes NEXT-4045 Validation: [vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo](https://vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo)
…config (#77905) When using both pages & app routers, during `next dev` and `next start`, if a function triggers a 404 error, we serve the app router not found page rather than the pages router one. When paired with the `i18n` configuration in `next.config`, the Next.js builder ignores the app router 404 and bundles the localized pages router 404 pages with the deployed functions. This leads to a 500 error, and is fixed in vercel/vercel#13222 However, to match the dev/start handling, we also need to update the `pages-manifest` so the builder knows to resolve `/404.html` and not the pages router variant when deployed. Fixes NEXT-4045 Validation: [vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo](https://vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo)
This PR was opened by the [Changesets release](https://github.com/changesets/action) GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated. # Releases ## vercel@41.6.0 ### Minor Changes - `vercel dev` will now automatically refresh the `VERCEL_OIDC_TOKEN` environment ([#13226](vercel/vercel#13226)) variable and restart the development server before it expires. ### Patch Changes - fix(auth): fix rendering fallback verification link ([#13232](vercel/vercel#13232)) - Updated dependencies \[[`8e1620805349484a3ee7944c4076c5d2c6f19ecc`](vercel/vercel@8e16208), [`134ea04feb1d534c6e6ebba8fdb2c698dc9477cf`](vercel/vercel@134ea04), [`d24262e058ee55fedfd03ab8f8197f840cd9c282`](vercel/vercel@d24262e)]: - @vercel/next@4.7.7 ## @vercel/firewall@0.1.7 ### Patch Changes - fix(readme): updated link to documentation about the SDK ([#13210](vercel/vercel#13210)) ## @vercel/next@4.7.7 ### Patch Changes - Fix for rewrite headers that ensures that we don't check post-non rewrite operations (like adding headers). ([#13229](vercel/vercel#13229)) - [next] ensure app router 404 page is still included in functions when using pages i18n ([#13222](vercel/vercel#13222)) - [next] improve error message for "No Next.js version" ([#13239](vercel/vercel#13239)) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
When using pages router, we bundle the localized static 404 file with every function output, to ensure that if not found behavior is triggered from a function, that it's available.
However, Next.js prioritizes serving the app router 404 page over the pages router 404 page. As a result, when triggering a not found error from an app router function, it'd trigger a 500 and crash the function because it only knows about
en/404.html
rather than404.html
(as an example).This ensures that we bundle the app router 404 page rather than the localized pages router 404 page if i18n + appDir is used. Separately in Next.js we need to ensure the
pages-manifest
is pointing localized paths to the correct not found file as well. This is accomplished in vercel/next.js#77905Without that change, this just solves the issue of throwing a 500 rather than resolving a 404 page, but doesn't fix the app router/pages router specificity issue.
Test plan
In the meantime, I manually validated it here:
https://vtest314-e2e-tests-bkc89ab40-ztanner.vercel.app/app-dir/foo