Every layout load returns 404 from server

Have configured a 404 custom error page.
Everytime a layut page is loaded in the browser or current page is refreshed, the 404 page is also returned. It does not do anything, but its a waste of resources.
If there is no 404 page configured, it works ok.

This is the piece of code that I found in lib\server.js that is causing this. Not sure what the fix is supposed to be:

    start: function(port) {
        // We add the 404 and 500 routes as last
        app.use((req, res) => {
            // if user has a custom 404 page, redirect to it
            if (req.accepts('html') && req.url != '/404' && app.get('has404')) {
                //res.redirect(303, '/404');
                res.status(404);
                req.url = '/404';
                app.handle(req, res);
            } else {
                res.status(404).json({
                    status: '404',
                    message: `${req.url} not found.`
                });
            }
        });

I didn't understand this bug report, if you want to clarify... :sweat_smile:

I though this much info would be good enough for Patrick.. but probably not :sweat_smile:

So if you have 404 configured, open any page in the browser, and look at the logs in Wappler WebServer tab. It will show the server returning the requested page, and the 404 page both. Serving templateView /404

NOTE: For some reason, I am seeing both the requested page and 404 being returned twice - although not sure if that is related to this 404 bug or some other issue in my code.

I only notice this behavior when I have the developer console open (running 6.8). Something about map files for dev console not found in a directory blah blah. When I close dev console, I don't see the 404 pages being served in my web server logs.