handling invalid routes / redirect logic
janezkk
PROOP

3 months ago

Hi team,

On VPS + Nginx, we could catch malformed URLs like:

domain.com/%list

Nginx would intercept this and throw an appropriate error or allow us to redirect to a valid URL.

After moving to Railway, the same URL now returns:

ERR_HTTP2_PROTOCOL_ERROR

We want to intercept these invalid routes and redirect to a valid URL, since some users already have this wrong link.

You can reproduce with the demo project: https://nextjs-test-production-2df7.up.railway.app/%product-list/0/50

$20 Bounty

7 Replies

3 months ago

I just get a 404 when visiting that link


janezkk
PROOP

3 months ago

It appears that Discord encodes the URL as %25 when the link is clicked. Please try copying and pasting the URL manually

https://nextjs-test-production-2df7.up.railway.app/%product-list/0/50


3 months ago

Ah gotcha, I assume our proxy is the thing that is throwing the error.


janezkk
PROOP

3 months ago

yes, but do we have any solutions?


3 months ago

Not from a platform side of things; I'll let the community make suggestions.


janezkk
PROOP

3 months ago

ok, thanks


fra
HOBBYTop 10% Contributor

3 months ago

you could probably add Nginx in front of your app (but that will probably increase the cost), or handle the redirects in your app?


Loading...