Just curious, what is the on-demand-entries-ping doing? It seems be happening every 5 or so seconds.
Is it normal or a bad implementation on my end that on every ping from on-demand-entries-ping a session is being stored in my mongodb sessions table (using https://github.com/jdesboeufs/connect-mongo)? I'm new to BE dev and express so i'm not 100% sure of the implications of that happening.
Thanks!
Next.js only build (and watch files) for your current active page (eg pages/index.js in /), that way your project can be huge and it's not going to use a lot of memory for HMR. That endpoint it's used for this feature, that way Next.js know which page you are developing.
Thanks @sergiodxa
@bliitzkrieg It's dev only. If you need, you can bypass that request from sessions stuff.
would this be the proper way to do so?
const server = express();
server.use((req, res, next) => {
if (opts.dev && req.path.match(/_next\/on-demand-entries-ping/)) {
return next();
}
// session logic here
// ex: server.use(session({ ... })) ...
});
server.listen(3000)
@juhaelee I believe express's server.use accepts a string as first argument so you can do server.use('some/path', session())
@juhaelee the first argument to express middleware can also accept a regex. This is how I'm using it:
server.use(/\/((?!_next\/on-demand-entries-ping).)*/, session({
// initialize express session here
}))
@msenevir you can ignore anything starts with /_next/ and /static/
Most helpful comment
Next.js only build (and watch files) for your current active page (eg
pages/index.jsin/), that way your project can be huge and it's not going to use a lot of memory for HMR. That endpoint it's used for this feature, that way Next.js know which page you are developing.