menu

ZEIT

Our mission is to make cloud computing as easy and accessible as mobile computing. You can find our Next.js community here.

Channels
Team

Custom 404 Page

November 26, 2018 at 1:14pm
Am using /static-build for a Gatsby site on v2 of Now, as per the official example.
The problem I have is that any missing route is served the internal Now 404 page, instead of my custom one. Is there something I should be doing under the routes key in my config to catch anything unmatched?
Show previous messages

April 25, 2019 at 9:54pm
People, we have support for custom 404 now! Please, test it and let me know. Documentation will be released in a few days:
"routes": [
{ "src": "/", "dest": "/index.html" },
{ "src": "/about", "dest": "/about.html" },
{ "src": "/blog/(.*)", "dest": "/blog/$1" },
{ "handle": "filesystem" },
{ "src": "/.*", "status": 404, "dest": "404.html" }
]
like-fill
6
  • reply
  • like

April 26, 2019 at 12:46pm
Hey ! I tried this with no luck. Is it live yet? Here's my now.json:
{
"version": 2,
"builds": [
{ "src": "index.html", "use": "@now/static" },
{ "src": "py.py", "use": "@now/python" },
{ "src": "js.js", "use": "@now/node" },
{ "src": "php.php", "use": "@now/php" },
{ "src": "go.go", "use": "@now/go" },
{ "src": "404.html", "use": "@now/static" }
],
"routes": [
{ "src": "/(.*)", "dest": "/$1" },
{ "handle": "filesystem" },
{ "src": "/.*", "status": 404, "dest": "404.html" }
]
}
When I go to <my-project>.now.sh/something I still get the same (default) 404 page.
  • reply
  • like
Great! I think I will wait for the docs first, in my case Im using a custom _error.js page and not sure how to route it properly
  • reply
  • like
We have a bug, sorry! It seems when you do "status": 404 our proxy is ignoring some needed logic for the custom 404. We are working on it as we speak!
  • reply
  • like

April 30, 2019 at 1:54pm
any updates?
  • reply
  • like
any updates?
Not yet. We are working on a few blockers first.
  • reply
  • like

May 3, 2019 at 6:33am
Thanks! Let me know if I can help out in any way. :)
  • reply
  • like

May 15, 2019 at 5:00pm
Any update on this??
  • reply
  • like

May 23, 2019 at 12:06pm
Is this resolved?
  • reply
  • like
Kinda, this is available but we are working on improvements.
"routes": [
{ "handle": "filesystem" },
{ "src": "/.*", "status": 404, "dest": "404.html" }
]
Edited
  • reply
  • like
Can´t get it to work with Gatsby and /static-build.
"builds": [ { "src": "www/package.json", "use": "/static-build", "config": { "distDir": "public" } } ], "routes": [ { "src": "/(.*)", "dest": "/www/$1" }, { "handle": "filesystem" }, { "src": "/.*", "status": 404, "dest": "/www/404.html" } ]
  • reply
  • like
Sorry, my first route was wrong.
  • reply
  • like

May 25, 2019 at 5:51am
Great! I think I will wait for the docs first, in my case Im using a custom _error.js page and not sure how to route it properly
do you have an ETA for Next.js specific routing?
Edited
  • reply
  • like

May 26, 2019 at 6:32pm
do you have an ETA for Next.js specific routing?
like-fill
1
  • reply
  • like

June 1, 2019 at 8:20am
just adding that I am also waiting for this to work 🙃
  • reply
  • like

June 18, 2019 at 2:25pm
Me to.
By the way: adding { "src": "/.*", "status": 404, "dest": "404.html" } to the route section of the now.json file made my app blank out in production (only a blanc page showed).
Edited
  • reply
  • like

June 24, 2019 at 10:28am
ZEIT has update default 404 page for servera times, so when could we serve our own 404 page?
  • reply
  • like
ZEIT has update default 404 page for servera times, so when could we serve our own 404 page?
You already can, but we have a bug on the status code and we are working to fix that.
  • reply
  • like

June 27, 2019 at 8:35pm
We fixed this issue. Now custom 404 is fully available!
like-fill
7
  • reply
  • like

July 3, 2019 at 3:18pm
Finally! Yes!
  • reply
  • like

July 11, 2019 at 8:01pm
Where can I find documentation on this?
  • reply
  • like
- i don't think it is in the documentation yet. I wrote about it here to help others outside of spectrum find the answer. https://khrome.dev/custom-404-pages-on-zeit-now-v2-platform
like-fill
2
  • reply
  • like
Just wondering how to take advance of a custom _error.js under nextjs I dont like the idea of having a html 404 page
  • reply
  • like
Thanks ! I'm kind of hoping they document it so the answers aren't only left in this thread or on other sites!
like-fill
1
  • reply
  • like

July 27, 2019 at 1:44am
Yes it works Thanks a lot :-)
  • reply
  • like
Show more messages
private
This channel has been archived