Skip to content

Debugging 403 forbidden when using NextJS / Rewrites #53

Answered by ezekg
neosavvy asked this question in Q&A
Discussion options

You must be logged in to vote

Thanks for the report here. This is a first. Per our email convo — this was caused by Vercel sending an X-Forwarded-Host that was not equal to api.keygen.sh. The host value, likely localhost or similar, was being rejected by our Rails app since that host is not allowed. As stated earlier, our application only allows a api.keygen.sh host. But what was odd here is that Rails cares about the proxied host by default. For us, we don't care about proxies and what the original host was.

To fix this, we've adjusted our Rails app to ignore the X-Forwarded-Host header entirely, since we don't use it, and we definitely don't want to reject valid requests based on the proxy host, only the actual Host.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ezekg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants