Is there a way to preserve ?_rsc query params on redirection with ISR on app router? (because Missing ?_rsc params cause CDN issue) #65783
Replies: 2 comments 2 replies
-
I had encounted the same issue. But i only use the step1. Step 1. remove all internal redirect ( triggered by user click) Below you can have a try. Step2. delete loading.js (DO NOT use streaming render - always 200 http status code) |
Beta Was this translation helpful? Give feedback.
-
@zecka Did you figure out how to spot the request in middleware? In our case, we have redirect in middleware, but see a lot of errors on rsc requests failing after redirect, presumably because redirect drops the search params. Thanks a lot for any advice! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I use redirection in some pages with
import { permanentRedirect } from 'next/navigation';
Once the website is build redirection work well but cause issue with CDN caching because of missing ?_rsc query params. (In my case CDN is Azure front door)
For example i have following redirection
website.com/news/my-article-old-url --> website.com/news/my-article-new-url
On prefetch or on router page change nextjs execute following request
website.com/news/my-article-old-url?_rsc=hash
with a header request Rsc=1.This request is redirect from
website.com/news/my-article-old-url?_rsc=hash
towebsite.com/news/my-article-new-url
and then CDN cache the rsc result as page result, so if we reload the page website.com/news/my-article-new-url we got json like response instead of html.I already try to intercept request with header Rsc=1 and without queryParams ?_rsc on middleware to add response header Cache-Control: no-cache. But _rsc query params and rsc header is always null on middleware...
Beta Was this translation helpful? Give feedback.
All reactions