fix(github): use public URL for OAuth + manifest callback redirects - #10
Merged
Merged
Conversation
Behind Railway's reverse proxy, Next.js's request.url reports the internal bind address (e.g. http://0.0.0.0:8080/...), not the public URL. Using `new URL(path, request.url)` to build redirect Location headers therefore sent users to the bind address — visible to the admin during the App-manifest "App created" redirect. Adds lib/request-url.ts with publicBaseUrlFromHeaders() and publicUrl() helpers that read x-forwarded-host + x-forwarded-proto (Railway's proxy adds these), ignoring 0.0.0.0 / 127.0.0.1 / localhost so they can never be baked into a Location. Patched both callbacks to use publicUrl(): - /api/github/setup-callback: post-manifest redirect to /admin/github/setup/done - /api/github/callback: post-install redirect to /settings/integrations/github The /admin/github/setup manifest builder already had its own equivalent fix in PR #8 (publicBaseUrl()); the callback redirects were missed. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause for the `https://0.0.0.0:8080/...\` redirects that kept showing up after the "App created" step. Behind Railway's reverse proxy, Next.js's `request.url` reports the internal bind address, not the public URL. `new URL(path, request.url)` therefore baked `0.0.0.0:8080` into every Location header — including the one that lands the admin on the secrets page.
PR #8 already fixed this for the manifest builder. This PR fixes it for the two callback handlers I missed:
Helper
New `lib/request-url.ts` with `publicBaseUrlFromHeaders()` + `publicUrl()` — reads `x-forwarded-host` + `x-forwarded-proto` (added by Railway's proxy), with a safety net that ignores any `0.0.0.0 / 127.0.0.1 / localhost` so those can never end up in a Location header.
Test plan
After merge + deploy:
🤖 Generated with Claude Code