HMR is not working for custom URL. If you redirect to index it will fail, if you redirect to another file, it will work.
npm run devBrowser updates
server.js file:
const express = require('express');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare()
.then(() => {
const server = express();
server.get('/test', (req, res) => {
app.render(req, res, '/index', {});
});
server.get('*', handle);
server.listen(3000, (err) => {
if (err) throw err;
console.log('> Ready on http://localhost:3000')
})
})
.catch((ex) => {
console.error(ex.stack);
process.exit(1)
});
/pages/index.js:
import React, { Component } from 'react';
class Index extends Component {
render() {
return (
<div>
<p>Hello Next.js</p>
</div>
)
}
}
export default Index;
Same issue 8.0.4-canary.6, work on 7.0.3, didn't work on 8.0.0
@dfvalero u can temp use workaround, create page called ex: main.js, don't use index.js until fix
@dmitweb That's what I did, I created a file called app.js. Thanks for the advice!
@dfvalero I tried out your example and after changing app.render(req, res, '/index', {}); to app.render(req, res, '/', {}); HMR appears to be working fine. Can you confirm this?
@ijjk y, works as expected
@ijjk Yes! :)
Most helpful comment
Same issue 8.0.4-canary.6, work on 7.0.3, didn't work on 8.0.0
@dfvalero u can temp use workaround, create page called ex: main.js, don't use index.js until fix