-
Notifications
You must be signed in to change notification settings - Fork 86
[Bug]: middleware on dynamic routes (deployed) #1168
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
Comments
Hi @JohnGemstone. Thanks for the report. I think this is essentially the same issue as #1114, but your excellent repro has helped me identify an actual bug in our rewrite handling code. Currently we need to run middleware at the origin, so we have to work around when there are static pages that would otherwise be served by the CDN. It seems that what we're missing is the case where dynamic pages have fallback=false and are statically-rendered. We correctly skip moving them to the CDN, but we don't ensure they use the SSR handler. Instead they are using an on-demand builder, which persists the first response (because usually it would just be generating the 404 page). I will fix that. |
I'm going to close this in favour of #1114, so please do subscribe there to keep track of this. |
Thanks for the quick turn around with this @ascorbic and reviewers. Will update the issue with the old branch URL for preservation's sake. |
Great! Thanks for letting us know. |
Just been told that any redirects declared in |
Hi @JohnGemstone , |
Hey @ascorbic, I've given it a go, and now I'm experiencing another bug. It's a bit of a narrow case but it seems like if you arrive at a middleware route from a next-rewrite, the middleware rewrite response is ignored. I have reproduced using the example above (make sure the cookie My next configmodule.exports = {
reactStrictMode: true,
async rewrites() {
return [
{
source: '/product-landing',
destination: '/dynamic-routes/product-1',
},
]
},
} I'll have a look to see if this can be side stepped using redirects instead, I guess part of the problem is having rewrites on rewrites! |
Summary
I'm using next middleware for A/B testing (by generating a cookie and rewrite to another URL depending on that cookie), but when using dynamic routes, I'm getting odd behavior. When I delete the cookie and revisit the page, the cookie is no longer generated. I've been able to reproduce the issue here with this site I made abtest-middleware.netlify.app. It compares the standard routing and dynamic behaviors.
Hopefully the repro site explains the issue well enough.
Works fine locally!
Steps to reproduce
abstest-dynamic
generatedCompare behavior to "/standard-routes"
A link to a reproduction repository
https://github.com/JohnGemstone/abtest-netlify-next
Plugin version
v4.2.1
More information about your build
netlify.toml
)What OS are you using?
Windows
Your netlify.toml file
No response
Your public/_redirects file
No response
Your
next.config.js
file`next.config.js`
module.exports = { reactStrictMode: true, }
Builds logs (or link to your logs)
Build logs
Function logs
No response
.next JSON files
generated .next JSON files
.next/required-server-files.json
.next/routes-manifest.json
.next/prerender-manifest.json
The text was updated successfully, but these errors were encountered: