This repository was archived by the owner on Mar 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Known issue: HMR not working on http://localhost:3000 for Next.js #8
Copy link
Copy link
Open
Description
Next.js comes with HMR, which is great. But it doesn't work on http://localhost:3000 yet.
It works on http://localhost:3001 though
But it would be a better developer experience to have everything working seamlessly on http://localhost:3000
- I tried to simply use
nextProxy(req, res)but gotTypeError: Cannot read property 'waitUntilReloaded' of undefined at HotReloader._callee7$ (/Users/vadorequest/dev/serverless-with-next/node_modules/next/dist/server/hot-reloader.js:658:44) - Then, I decided to proxy requests that Express doesn't want to handle to 3001, so that Next.js app handles them. But the proxy messes up with HMR and I haven't been able to fix it:
- I tried to proxy all
/_nextby doingapp.use('/_next/', proxy('http://localhost:3001/_next/'));but then I get 404 for all js scripts likehttp://localhost:3000/_next/-/main.js - I tried to proxy them all one by one but then they return HTML content instead of JS (basically the index page), ex:
app.use('/_next/-/main.js', proxy('http://localhost:3001/_next/-/main.js')); - If you manually browse to
http://localhost:3001/_next/-/main.jsit works okay and return the actual JS file - I tried to disable HMR by setting
dev: falsebut then the Next.js app complainsCould not find a valid build in the '.next' directory! - I tried to force contentType to
text/event-streamwhen proxying/_next/webpack-hmrand it seem to work okay as long as Express doesn't catch the request first
(which is the case with GET/:level1/:level2route), and it does display[HMR] connectedbut nothing happens when a file is changed.
- I tried to proxy all
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels