Middleware + Incremental Regeneration not working
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
–
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
res.unstable_revalidate(path) was working fine when using a _middleware previously, but in the last few days it wasn’t working. It would call the get request on the path just fine, but that wasn’t causing the cache to break.
I removed the _middleware.js and it all worked fine. I added the _middleware back in, and again, cache wouldn’t break.
I feel like something must have changed on vercel / next side?
( PS. I dont know if this is happening in canary release )
( PSS. Sorry about the basic issue, but I just wanted to report the issue )
Expected Behavior
Invalidate the cached page.
Link to reproduction
–
To Reproduce
The _middle wasn’t fancy, just making paths like this: /something-page-PAGEID and it was getting the PAGEID at the end, and doing:
const url = req.nextUrl.clone() let path = req.nextUrl.pathname let getId = path.substr(path.lastIndexOf(‘-’) + 1)
url.pathname = ${getId}
return NextResponse.rewrite(url)
Issue Analytics
- State:
- Created a year ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
@nicosh that appears to be different as the error is failing to write the file due to the
:
character being used in the filename which isn’t allowed on Windows. You could resolve this by ensuring that character is not included in the path e.g. strip theport
info from thecurrentHost
valueBelieve this is causing my current setup issues as I’m trying to upgraded to the latest 12.2. I use middleware to pass the specific domain for the site (allows for multiple custom domains).
getStaticProps
needs the domain info to function. This works great for normal views of pages. But when revalidate tries to hitgetStaticPaths
it now doesn’t have the domain data that it needs. Is there a different way to do this in the new version?