404 page route is overwriting Stripe webhook route

I set up a 404 route as follows: image

The goal of that route is to show a pretty 404 page when an url can’t be found.

This worked fine, until I realised this is blocking my webhooks from stripe.

With that route set up the /webhooks/stripe url will be routed to the 404 page:

This makes sense as that’s what I said up in the routes… but this is not what I want.
So I thought - I’ll just make another route to /webhooks/stripe above my /* 404 route.

But I am not sure which Route Properties to set.

I want a 404 page and I want the webhooks to be reachable.
How can I get both working?

Gentle bump

lib/setup/routes.js
Line 210

webhooks(app);

Move it to line 34, before the if condition:

// Line 34
if (fs.existsSync('app/config/routes.json')) {

If it works, tag Patrick so he can fix it permanently (these changes are lost with a Wappler update)

Thanks!! It appears to work :slight_smile:
I can now access the stripe webhooks folder but all other urls that don’t have a route go to the 404 page:

By setting the 404 page like this:
image

@patrick - can this be a permanent change?:

Revert the changes I’ve shown you

Go to lib/server.js, line 55:

// We add the 404 and 500 routes as last
        app.use((req, res) => {
            res.status(404).json({
                status: '404',
                message: `${req.url} not found.`
            });
        });

You have to edit that somehow :slight_smile:

George recommends creating the 404 page like this: Routing setting for 404 on NodeJS

So I’m thinking there are 2 ways to do this:

  1. Apply the change you recommended @Apple in routes.js
  2. A new option in the UI to set a 404 route, which is then added to the server.js file

Option 2 seems more user friendly @patrick

Bump. A /* route still breaks /webhooks/ links. But this s the recommended way:

@patrick @George

This seems like a simple change to fix a big issue (and it works)…any reason to not include soon?

Please check Creating Custom Error Pages in NodeJS