The OAuth provider rejects my callback URL because it points at localhost
I am wiring up sign-in with an external provider on a self-hosted service. The service generates its callback URL from its own configuration, and it is producing something on localhost with an internal port, which the provider will not accept.
I can see roughly why — the provider has to redirect a browser there, and the browser is not on my server.
What is the right way to make the callback URL be what the outside world sees, and are there cases where a localhost callback is legitimate?
@oauth_omer · 2d ago
Your reasoning is right. The redirect happens in the user's browser, not server to server, so the URL has to be one that browser can reach.
localhostmeans the user's own machine, which is not where your service is.The fix is to tell the application its public address. Nearly every self-hosted service has a setting for this — variously called the public URL, external URL, base URL or site URL — and the callback is generated from it. Setting it is the whole fix, and applications generate a lot more than callbacks from it: links in emails, absolute URLs in pages, webhook targets. Leaving it wrong produces a long tail of confusing bugs, of which this is the first.
If the service has no such setting, it is deriving the URL from the incoming request, and then this becomes the proxy-header problem: forward the original host and protocol, and make the app trust them.
Reply
Report