Closed sedubois closed 7 years ago
Hey, thanks for using it!
The /:slug
route is indeed the problem, you can solve it with something like this in server.js
:
const nextHandler = app.getRequestHandler();
const routesHandler = routes.getRequestHandler(app);
app.prepare().then(() => {
const server = express();
const nextPaths = [
'/_next/',
'/_webpack/',
'/__webpack_hmr',
'/static/'
];
server.use((req, res) => {
if (nextPaths.some(path => req.url.startsWith(path))) {
nextHandler(req, res)
} else {
routesHandler(req, res)
}
}).listen(3000)
});
Thanks 👍 Considering that this package aims to simplify routing, could it be improved to take care of this itself?
You're right, this is now baked in.
Please run:
npm update --save next-routes
:beer:
Thanks, it works!
I'm trying to simplify my webapp by using your package, thanks for providing! 👍
Here is my attempt: https://github.com/relatenow/relate/compare/next-routes
However, I get
EventSource's response has a MIME type ("text/html") that is not "text/event-stream". Aborting the connection.
Maybe it's because I have a route
/:slug
which, when not handled properly, might also match Next.js' internal routes such as __webpack_hmr etc.How can this be fixed?