assetPrefix is not respected #28702
ScriptedAlchemy
started this conversation in
Ideas
Replies: 2 comments 2 replies
-
Overriding internals like |
Beta Was this translation helpful? Give feedback.
1 reply
-
Solved by hacking around next/heads own context provider. class LuluHead extends Head {
render() {
return (
// eslint-disable-next-line react/jsx-pascal-case
<Head.contextType.Consumer>
{/* eslint-disable-next-line react/jsx-pascal-case */}
{value => <Head.contextType.Provider value={Object.assign(value, { assetPrefix: global.__dynamicAssetPrefix || '' })}>{super.render()}</Head.contextType.Provider>}
</Head.contextType.Consumer>
);
} |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
What version of Next.js are you using?
11.1.2
What version of Node.js are you using?
14
What browser are you using?
chrome
What operating system are you using?
macOS
How are you deploying your application?
AWS SLS
Describe the Bug
Out ephemeral environments are configured during deploy via an env var. As of next 11.1.2, the assetPrefix does not seem to be respected and css & js assets are always loaded from the domain.
We use a pr query string to proxy to the right AWS buckets through stage.site.com.
We change the assetPrefix during SSR like this
If I look in
__NEXT_DATA__
, i see my empheral URL listed there which would point my assets to the right origin, but SSR does not seem to respect it.So my assets end up loading from stage.site.com/assets instead of prenv33.preprod.site.com/assets
Elsewhere in out app, we configure the asset prefix as follows
Expected Behavior
Asset prefix should be respected as its shown in
__NEXT_DATA__
To Reproduce
Try changing the asset prefix dynamically in the route handler or custom app
Beta Was this translation helpful? Give feedback.
All reactions