-
Notifications
You must be signed in to change notification settings - Fork 97
fix: add text/x-component header to .rsc assets generated at build time, don't use rsc-data edge function when hitting .rsc path directly #2290
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
…me, don't use rsc-data edge function when hitting .rsc path directly
✅ Deploy Preview for netlify-plugin-nextjs-nx-monorepo-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-plugin-edge-middleware ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-next-auth-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for nextjs-plugin-custom-routes-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-static-root-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-demo-all-flags ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-plugin-canary ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for netlify-plugin-nextjs-export-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for next-i18next-demo ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
|
I think the reason was because at the time at least Next didn't request |
|
Superseded by v5. |
Description
When working on something else I noticed quite the weirdness with how
rsc-datamiddleware behaves when it comes to routing:as

/blog/erica/first-post.rscis actually asset produced at build time:so only the first request from logs above one worked correctly. Second one did seem to work, but instead of using static asset on CDN it wen't to lambda to generate it and third one I don't even remember but it definitely seems wrong.
I'm not exactly sure why we make edge middleware to handle requests for
.rscpaths - when trying that path we should just use path as-is - it will either use static asset from CDN or go to lambda to generate it (and possibly cache with with ODB). I did remove that from this PR as it didn't make sense to me, especially as it was redirecting to/blog/erica/first-post.rsc.rscwhich seems all kind of wrong thing to do.The statically produced .rsc files also didn't get expected
text/x-componentheader (we only get this header right now when request is handled by lambda), so I also added header rule to ensure those get expected headers.And finally I'm not sure why the rsc-data would want to rewrite to paths that end with trailing slash (
.rsc/) - the comment say to differentiate those for ODB, but with no clarity why you want to do that? It also meant that if user hit path with trailing slash it would never use static assets on CDN and would always need to go through lambdaDocumentation
Tests
You can test this change yourself like so:
Relevant links (GitHub issues, etc.) or a picture of cute animal