karh
January 20, 2022, 11:27am
1
I set up a 404 route as follows:
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?
Apple
January 27, 2022, 12:04pm
3
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)
karh
January 27, 2022, 1:14pm
4
Thanks!! It appears to work
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:
@patrick - can this be a permanent change?:
Apple:
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)
Apple
January 27, 2022, 1:22pm
5
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
karh
January 27, 2022, 2:02pm
6
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:
Apply the change you recommended @Apple in routes.js
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
karh
February 20, 2023, 2:30pm
7
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?
Apple:
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)
Teodor
April 11, 2024, 8:00pm
9