Rewrites (issue)

Hi All,
we are using rewrites to proxy requests to external domains. While this works functionally, the static assets (e.g., JavaScript chunks, images, etc.) required for the rewritten destination are not being loaded correctly unless the domain is explicitly set using the assetPrefix configuration in next.config.js.

Next.js only allows a single string value for assetPrefix, and does not support an array of domains. This becomes a limitation when we want to proxy to multiple domains, as we cannot define multiple asset prefixes to support all the rewritten destinations.

As a result, asset loading fails for rewritten routes that do not match the single domain defined in assetPrefix.

any help is appreciated !

Hey @vishnumallela-oracze, welcome!

Can you explain a little more about your rewrite setup?

The assetPrefix is mainly there to introducs a unified external CDN. Typically, if you need some finer grained control for complicated rewrites, i tend to leverage a custom middleware.

More than happy to dive deeper, lemme know!