HMR with custom server
Unanswered
Derock posted this in #help-forum
DerockOP
so far, I've figured out you can get an upgrade handler (similar to the request handler) with
but the function being returned is a noop:
I verified this by adding a
I am creating my next.js app like this:
nextApp.getUpgradeHandler()
but the function being returned is a noop:
// node_modules/next/dist/server/next-server.js:198
async handleUpgrade() {
// The web server does not support web sockets, it's only used for HMR in
// development.
}
I verified this by adding a
throw new Error("...")
into the function and called.I am creating my next.js app like this:
import next from "next";
const nextApp = next({
dev: env.dev, // I've console.log'd this and confirmed it is `true`
hostname: env.host,
port: env.port,
});
await nextApp.prepare(); // I have top level await support
const handle = nextApp.getRequestHandler();
const handleUpgrade = nextApp.getUpgradeHandler();