Closed mbj36 closed 6 years ago
Sorry, i configured my server incorrectly
@mbj36 I'm facing the same issue. Could you please clarify what exactly was wrong with the server configuration? Maybe I need to apply the same fix.
I was having the same problem, but turns out the solution was really simple: needed to restart the server between switching Git branches. 🙃
P.S. I've figured it out myself. Adding the following code solved it for me:
const customRoutes = require('./routes/custom')
const expressApp = Express()
expressApp.all('/custom/*', customRoutes.getRequestHandler(app))
Hi guys, i've same issue with default example on the README. Anyone have fallback ?
How do you start the server?
Hi @fridays
If i run my server with node server.js
, express return Client pings, but there's no entry for page: /
With next
command, all route working, but the hard refresh return an 404 error.
My server.js :
const next = require('next')
const routes = require('./config/routes')
const app = next({ dev: process.env.NODE_ENV !== 'production' })
const handle = routes.getRequestHandler(app)
const express = require('express');
app.prepare().then(() => {
const server = express();
server.use(handle);
server.get('/inscription', (req, res) => {
return app.render(req, res, '/inscription', req.query);
});
server.get('*', (req, res) => {
return handle(req, res);
});
server.listen(3000, (err) => {
if (err) throw err;
console.log('Server ready on http://localhost:3000');
});
});
Hey @fridays
Thanks for making this, it's really helpful - Whenever i hard refresh my custom routes, it gives 404 error, when i go through
<Link>
it just works fineAny thing which i might be missing ?