Next.js Discord

Discord Forum

Reverse Proxy Issue with ISR/SSG

Unanswered
Iridescent shark posted this in #help-forum
Open in Discord
Avatar
Iridescent sharkOP
Has anyone ever put a SSG page behind a reverse-proxy with path rewriting? I'm using page router and my dynamic route is:

[market]/[country]/[language]/home

Users visit my site with just the country/language in the path - like example.com/ca/en and my CDN (Fastly) rewrites the path to my Next app and injects the market portion of the path. This works fine when my pages are rendered SSR with getServerSideProps, but when I try to turn my page into an ISR SSG page, I get an error:

The provided as value (/ca/en) is incompatible with the href value (/[market]/[country]/[language]/home) -

I've traced this into Next's Container's componentDidMount method.

if (router.isSsr && (initialData.isFallback /* more */) { router.replace(...) }

It's at this point the exception gets thrown - when trying to do router.replace. The difference with SSG is that initialData.isFallback=false, but when I make my page ISR initialData.isFallback=true.

These errors are all client-side btw. Is there something I can do to make Next understand what I'm doing with the reverse-proxy pathname rewrites?

0 Replies