Since there is no way of handling the 404 responses natively from within Wappler itself, I would suggest to go a more "hacky" way and use the internal server itself, you can locate it here:
I can’t get the view (and layout) to render though. Any thoughts?
Routes correctly for any non existing URL, sends the correct 404 response, found that I need to define the layout (Googled ejs layouts), but returns a page with {} if I attempt to use render.
This is inside a 404.js file at extensions/server_connect_routes as mentioned in your link.
If I return anything else, ie res.status(400).send('Not found') or res.sendStatus(404) it works fine (obviously doesn’t render the 404 page though.
Also you could make a redirect to a predefined 404 route from your SC workflow.
The dev I work with would probably say…nope…nope. This isn’t ‘the right way’.
I also attempted to hijack the error response in server.js as @0x90 mentioned (https://community.wappler.io/u/0x90) to see if I could render() the page there. But returns exactly the same thing, ie won’t render the view.
File name for view is correct and exists, as it works in Wapplers ‘routing’. So has me stumped.
Just remember 404 has to be the final entry in the routing panel! By default new routes will be added after it and will not be displayed. They will require to be dragged above the route for your 404 page.
I did it and in this way I have response status 200 but I would like have a 404 response because for SEO It is better. Is it possible? thanks very much!
Ok, I agre to you but I have a question.
If, unfortunately, the site is hacked and the home page is linked to many pages “fake” (see below) and google indexes them, after fixing and cleaning the siteI would like to remove those links from the google search console and be sure to have a 404 status as recommended by google itself.
For example if my site is:
-ww.mysite.com
If It hacked I could have:
-ww.mysite.com/fnjdshf
-ww.mysite.com/yruroabdis
-ww.mysite.com/tehweja
-ww.mysite.com/tehwejaerqade