404 status for catch-all route

Based on my own stupidity trying to figure out something that didn’t really need figuring out I found a small omission in routing.

To be compliant with http status codes the catch-all route should set a 404 status on the response. Right now it will send a 200 OK.

There should probably be an option in the routing panel to set the status to 404 for a catch-all route(*)

To workaround this, instead of creating the catch-all on the routing panel, create a small middleware and place it in extensions/server_connect/routes/404.js

exports.after = function (app) {
    app.get('*', (req, res) => {
        res.status(404).sendfile('404.html', { root: 'public' });
    });
}

This will render the 404.html file stored in /public and set the response to 404.

Community Page
Last updated: