Not Found message from Route Handlers
Unanswered
Milkfish posted this in #help-forum
MilkfishOP
Hi guys, trying to return a Not Found from a GET request in a route handler.
The 404 does get sent, but it returns a blank page instead of the contents of the not-found file.
Not sure if this is a bug, or by design of the API - but is there a way to make this work without importing the not-found file into the route handler itself?
The 404 does get sent, but it returns a blank page instead of the contents of the not-found file.
Not sure if this is a bug, or by design of the API - but is there a way to make this work without importing the not-found file into the route handler itself?
12 Replies
@Milkfish Hi guys, trying to return a Not Found from a GET request in a route handler.
The 404 does get sent, but it returns a blank page instead of the contents of the not-found file.
Not sure if this is a bug, or by design of the API - but is there a way to make this work without importing the not-found file into the route handler itself?
notFound() should give you the root not-found file
If you simply return a response with status 404, it will be treated like any other responses with any other statuses and the not-found file is not triggered
MilkfishOP
That's what I assumed too - doesn't seem to be the case
Minimal reproduction, where it shows that notFound only returns a blank page from within a route handler
@Milkfish https://codesandbox.io/p/sandbox/focused-heyrovsky-gr3683?file=%2Fapp%2Ftest%2Froute.ts%3A3%2C14
ohh i see, indeed it only sends an empty 404
hmm
MilkfishOP
Yep....... not sure if I should raise a bug report, or if it's a feature haha
if you need the 404 page, ig you should redirect to any non-existent page
redirect("/404")MilkfishOP
Yep - that was my last resort, the 404 URL doesn't make a tonne of sense in this instance, so will have to revisit