Next.js Discord

Discord Forum

Dynamic absolute path for `_next/` files

Unanswered
Northern Saw-whet Owl posted this in #help-forum
Open in Discord
Northern Saw-whet OwlOP
I want to implement a feature that allows users to host subdirectory pages via my application. For example usersite.com/page will point to page.mysite.com which works fine.

However, I'm facing an issue with Next.js static files, those that are under _next/... since they are served via a relative path and not an absolute one. Thus those files are trying to be fetched from usersite.com/_next/... (which they don't exist in) rather than page.mysite.com/_next/... or usersite.com/page/_next/....

Since that's fully dynamic I can't use assetPrefix in build time. Any help how I could achieve the correct behavior?

0 Replies