-
Notifications
You must be signed in to change notification settings - Fork 86
fix: data route rewrite for i18n root route #2002
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
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
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.
@@ -74,7 +74,7 @@ export const generateNetlifyRoutes = ({ | |||
}) => [...(withData ? toNetlifyRoute(dataRoute) : []), ...toNetlifyRoute(route)] | |||
|
|||
export const routeToDataRoute = (route: string, buildId: string, locale?: string) => | |||
`/_next/data/${buildId}${locale ? `/${locale}` : ''}${route === '/' ? '/index' : route}.json` | |||
`/_next/data/${buildId}${locale ? `/${locale}` : ''}${route === '/' ? (locale ? '' : '/index') : route}.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.
[dust] I get what's happening here but it's hard to grok with the multiple/nested ternaries.
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.
yeah, I agree. i did try to refactor this but ended up in a knot because it really needs to broken up into 2 different functions - one for i18n and one for non-i18n - but it's difficult because of the various places it gets called. hopefully all this will be replaced soon with edge routing and/or improved CDN redirects
Summary
The runtime creates rewrites that route ISR pages (and their data routes) to the ODB handler. However, the runtime was not correctly handling data route rewrites on ISR index pages for i18n sites.
On non-i18n sites, the index data route has the 'index' suffix, e.g.
/_next/data/build-id/index.json
On i18n sites, the index data route uses the locale instead, e.g.
/_next/data/build-id/en.json
, but the runtime was still using the 'index' suffix. This PR fixes that.Test plan
/_next/data/build-id/en.json
instead of/_next/data/build-id/index.json
x-nf-render-mode: odb ttl=60
header and not anx-nf-render-mode: ssr
headerRelevant links (GitHub issues, Notion docs, etc.) or a picture of cute animal
Closes netlify/pod-ecosystem-frameworks#429