Hello! Right, so I’m looking to create custom error pages for common error codes, I have the 404 and I’d like to do the 429 too many requests now - is there a way to do this? I am ising express, but I don’t really know how it works. Any help would be greatly appreciated! Thanks in advance!
Thats a good question!
This will do the trick:
app.get('/', (req, res) => res.send('429 Error', 429))
Using curl -I (glitch site)
I got:
HTTP/1.1 429 Too Many Requests
Hey there, you can do what RiversideRocks mentioned or use res.status(429).send("Too Many Requests")
@ItsYanko @RiversideRocks He is asking for a custom 429 page, with his own HTML code saying “429: too many requests”
Theres a way to redirect a file on 404 requests that I am aware
app.get('*', (req, res) => [function])
But im unsure on 429 requests.
Yes, that’s correct. And @ItsYanko, if that’s the case, could I use that to display this page?
or you can send a file:
app.use((req, res) => {
res.status(429).sendFile('./too-many-requests.html');
});
update: yay! my first solution!
Ah, thanks! That’s what I was looking for! Sadly I can’t test it because I’ll never get too many requests, but thanks! Will this work for all error codes?
I made something like this
You have a double “n” in many
I got a error, app.stats is not a function
app.status
is what @DerDer56 was referring to. I haven’t tried myself
Yes, you can do this for 404s as well!
status not stats
Nice, however, when you try to go home it will just show that again
Can you do it for others as well?
of course! 404, 403, 429, you name it!
even the 202 error code?
i’m not sure, but probably yes
yes, @DerDer56 made it!