Server rendered 404 page
See original GitHub issueHi!
I’m trying to use slug in my article page. It’s work when I click in article link, but when I enter directly from URL or I reload the page, I get 404 error.
I tried with and without express server using both of examples in next-routes
README.
My /routes.js
file:
const routes = require('next-routes');
module.exports = routes().add({
name: 'post',
pattern: 'posts/:slug-:id([^-]+)',
page: 'post_public'
});
My server.js
file:
const next = require('next')
const routes = require('./routes')
const app = next({dev: process.env.NODE_ENV !== 'production'})
const handler = routes.getRequestHandler(app)
const express = require('express')
app.prepare().then(() => {
express().use(handler).listen(3000)
})
package.json
{
"name": "create-next-example-app",
"scripts": {
"dev": "node server.js",
"build": "next build",
"start": "NODE_ENV=production node server.js"
},
"dependencies": {
"express": "^4.16.4",
"next": "^7.0.2",
"next-routes": "^1.4.2",
"react": "^16.6.3",
"react-dom": "^16.6.3"
}
}
Any ideas what I’m doing wrong?
update
Version with error: https://github.com/highlabs/next-routes-test Live url: https://create-next-example-app-bftspwtpwy.now.sh/
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:11
Top Results From Across the Web
404 Not Found Pages | Error Handling - YouTube
404 Not Found Pages Error Handling Server Server Side Rendering with React and ReduxSubscribe ...
Read more >How to return 404 page for a server-side rendered dynamic ...
I'm working on a next.js project with Contentful as Content Management System. I want to return the 404 page for a server-side rendered...
Read more >How To Properly Serve 404 Errors on SPAs (with SEO in Mind)
Redirect Broken URLs to a Stand-Alone 404 Page; Inclusion; Exclusion; Isomorphic Rendering; Simple Server Side; Serve a 404 Component ...
Read more >Return a 404 from a Next.js page render method (ssr + client ...
Allow to render the error page + return the correct error code with SSR. // It is a hack and has the disadvantage...
Read more >Basic Features: Pages - Next.js
Two forms of Pre-rendering · Static Generation (Recommended): The HTML is generated at build time and will be reused on each request. ·...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This project is dead?
I have the same error, but on production build