Next.js Discord

Discord Forum

Re-write rule /_next/

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
So we have our site hosted on Vercel, say the domain it's hosted at is https://vercel-production.generalassemb.ly.com ... We have Switchboard which is putting a proxy in-front of that, so you access the site at https://generalassemb.ly/employer ... When this happens, assets are trying to be loaded from the root, so /_next/** . This obviously does not work because those assets do not exist on the root domain, they live on the Vercel domain.

We updated our next.config.js file to include assetPrefix which prepends the correct process.env.PUBLIC_URL. This works for .js, .css, .fonts... Where this doesn't work is images being optimized with next/image and also Link component preloading. Both of those items continue to point to /_next/ which we want to be https://vercel-production.generalassemb.ly.com/_next/

Any creative ideas? We've tried adding a rewrite rule in the next.config.js file with no luck.

0 Replies