Link to the code that reproduces this issue
https://github.com/thany/repro-assetprefix-hmr-error
To Reproduce
- Take the reproduction template
- Set
assetPrefix: 'http://localhost:3000' in next.config.js
- Run
npm run dev
That's it. You can also try a different value for assetPrefix, like /public or just /. It's all the same.
Current vs. Expected behavior
Every request to webpack-hmr will either fail or keep loading indefinitely.
In Firefox this is best visible, as Chrome acts as if these requests load just fine and then displays "provisional headers". In Firefox you can see it loading indefinitely very cleary. I've also seen Firefox error on them with NS_ERROR_NET_RESET. However with the above repro you will see them loading forever.
I would expect it to just work.
Provide environment information
Operating System:
Platform: win32
Arch: x64
Version: Windows 10 Pro
Binaries:
Node: 20.11.1
npm: N/A
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 14.1.4
eslint-config-next: 14.1.4
react: 18.2.0
react-dom: 18.2.0
typescript: 5.4.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
The only way to get HMR to work is to leave assetPrefix an empty string or undefined. However even on our development setup, this is not workable, because of reasons that go beyond the scope of Next.js. The point is, it just has to work with assetPrefix: 'http://localhost:3000'.
Also good to know, this problem started happening probably after upgrading to Next.js 14, but certain circumstances didn't allow us to pay good attention to when exact this still worked. Definitely in Next.js 13.x, but unsure which version. If this helps to know, I can figure it out, lemme know.
Link to the code that reproduces this issue
https://github.com/thany/repro-assetprefix-hmr-error
To Reproduce
assetPrefix: 'http://localhost:3000'innext.config.jsnpm run devThat's it. You can also try a different value for assetPrefix, like
/publicor just/. It's all the same.Current vs. Expected behavior
Every request to
webpack-hmrwill either fail or keep loading indefinitely.In Firefox this is best visible, as Chrome acts as if these requests load just fine and then displays "provisional headers". In Firefox you can see it loading indefinitely very cleary. I've also seen Firefox error on them with NS_ERROR_NET_RESET. However with the above repro you will see them loading forever.
I would expect it to just work.
Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
next dev (local)
Additional context
The only way to get HMR to work is to leave
assetPrefixan empty string or undefined. However even on our development setup, this is not workable, because of reasons that go beyond the scope of Next.js. The point is, it just has to work withassetPrefix: 'http://localhost:3000'.Also good to know, this problem started happening probably after upgrading to Next.js 14, but certain circumstances didn't allow us to pay good attention to when exact this still worked. Definitely in Next.js 13.x, but unsure which version. If this helps to know, I can figure it out, lemme know.