René's URL Explorer Experiment


Title: fix(api): resolve the OAuth callback's app origin from configured APP_URL by glifocat · Pull Request #421 · onecli/onecli · GitHub

Open Graph Title: fix(api): resolve the OAuth callback's app origin from configured APP_URL by glifocat · Pull Request #421 · onecli/onecli

X Title: fix(api): resolve the OAuth callback's app origin from configured APP_URL by glifocat · Pull Request #421 · onecli/onecli

Description: I have read the CONTRIBUTING.md file. YES What kind of change does this PR introduce? Bug fix. Fixes #420. Maintainer note. @glifocat's diagnosis here was exactly right, and the fix proposed in the issue (#420) was the correct design — read the raw env so it is undefined when unset, and let the existing || apiOrigin fallback finally run. That is what this PR now implements. The version that had been pushed to the branch simplified it further, to const appOrigin = apiOrigin, and that turned out to break deployments that serve the API and the dashboard on different hosts (details below). I've reset the branch to main, re-applied the fix against current code, and extended it to the other places with the same defect. Credit for finding this is entirely @glifocat's — thanks for the unusually clear write-up, including pinning the exact line and commit. The bug packages/api/src/routes/apps.ts picked the callback's redirect target with: const appOrigin = APP_URL || apiOrigin; APP_URL there is the constant from lib/env.ts, which defaults to http://localhost:10254. It is never falsy, so || apiOrigin was unreachable dead code. Self-hosters who had not set APP_URL completed provider consent and were then sent to localhost. Also reported independently in #192. Why not "just use the request origin" Those are two different questions, and conflating them is what caused this in the first place: Who answered this request? → getRequestOrigin() Where does a browser go for a dashboard page? → not necessarily the same host A deployment can run this API package standalone — answering on an API host and declaring it via the selfUrl option — while the dashboard is served elsewhere. CLI and SDK clients talk to the API host, so a browser really can arrive at the callback there. But /app-connect/* is a Next.js page that only exists on the dashboard host, so the last redirect has to cross origins, and it can only do that from a configured APP_URL. apps-callback-origin.test.ts locks that in: with selfUrl on one host and APP_URL on another, the redirect must land on the dashboard host. It fails with https://api.example.com/app-connect/... if the preference is dropped — the literal dead URL a user would hit. The fix lib/app-origin.ts (new) — configuredAppUrl() returns the explicitly configured URL, or undefined when unset/empty/whitespace. That undefined is the whole point: it is what lets a call site say "…and otherwise use the request origin". Plus originFromHeaders(), the header-derivation logic lifted out of request-origin.ts. getAppOrigin(request) in lib/request-origin.ts — names the invariant so it is harder to break: configured APP_URL first, request origin only as the fallback. Applied at the callback and at the agent-facing "go set up your credentials" link (dashboardUrl gained an optional fallback origin). Settings → Instance now shows the origin actually in use, with an auto-detected note. Side benefit: that page was statically prerendered, so it had been displaying its build-time APP_URL; it is dynamic now. originFromHeaders() validates the host and scheme it derives. These origins reach Location headers and, on the OAuth fragment-bridge path, the inside of a . Deployment APP_URL request origin result single host set same unchanged split API / dashboard hosts set differs redirect stays on the dashboard host self-hosted, set set = it unchanged self-hosted, unset unset derived fixed Not included The docker-compose.yml APP_URL pin. Unpinning it is right in principle — deriving a public URL from a bind address is a category error — but scripts/install.sh auto-selects the docker0 bridge IP on bare-metal Linux and publishes only there, so 127.0.0.1:10254 is not listening. The gateway builds absolute links with no request to derive from (apps/gateway/src/gateway/response.rs), and unpinning alone would point those at a dead localhost. Those two have to change together; tracked separately. Verification @onecli/api: check-types, lint (--max-warnings 0), 715 tests passing. @onecli/web: check-types, lint. Prettier clean. Each regression test was confirmed to fail against the original bug before being kept.

Open Graph Description: I have read the CONTRIBUTING.md file. YES What kind of change does this PR introduce? Bug fix. Fixes #420. Maintainer note. @glifocat's diagnosis here was exactly right, and the fix proposed ...

X Description: I have read the CONTRIBUTING.md file. YES What kind of change does this PR introduce? Bug fix. Fixes #420. Maintainer note. @glifocat's diagnosis here was exactly right, and the fix propo...

Opengraph URL: https://github.com/onecli/onecli/pull/421

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:f4adb097-96c3-c0ee-ae3e-5f4896ee2c69
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idCD32:35F95A:378BF4B:4991FCD:6A6557A6
html-safe-nonceb5d00077657abbf8aa59e793e82288f3c0574eb2dc36d19e0ff97945e1c33fe0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDMyOjM1Rjk1QTozNzhCRjRCOjQ5OTFGQ0Q6NkE2NTU3QTYiLCJ2aXNpdG9yX2lkIjoiODg1OTk5OTMyNDE1MzkyNzU5MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmaccbcfdf0f5e5d367df6c0540934b497ca5f4b3284cf11ee649dda911467a12ed4
hovercard-subject-tagpull_request:4016852745
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
twitter:imagehttps://avatars.githubusercontent.com/u/12087426?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/12087426?s=400&v=4
og:image:altI have read the CONTRIBUTING.md file. YES What kind of change does this PR introduce? Bug fix. Fixes #420. Maintainer note. @glifocat's diagnosis here was exactly right, and the fix proposed ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None52c76df668885aaff23b50bdca1fa1ea44ac9c1553e888ebc70ff1e4daa4625b
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/onecli/onecli git https://github.com/onecli/onecli.git
octolytics-dimension-user_id263660444
octolytics-dimension-user_loginonecli
octolytics-dimension-repository_id1175900220
octolytics-dimension-repository_nwoonecli/onecli
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id1175900220
octolytics-dimension-repository_network_root_nwoonecli/onecli
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release309153364422b3c499922d1a2a6404910a58ed8e
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fonecli%2Fonecli%2Fpull%2F421%2Fcommits%2F75bd42201b28f75e04fc39e4aa2b27f1e1713d83
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
Code QualityEnforce quality at mergehttps://github.com/features/code-quality
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/open-source/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/open-source/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fonecli%2Fonecli%2Fpull%2F421%2Fcommits%2F75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=onecli%2Fonecli
Reloadhttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Reloadhttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Reloadhttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Please reload this pagehttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
onecli https://github.com/onecli
oneclihttps://github.com/onecli/onecli
Notifications https://github.com/login?return_to=%2Fonecli%2Fonecli
Fork 162 https://github.com/login?return_to=%2Fonecli%2Fonecli
Star 2.8k https://github.com/login?return_to=%2Fonecli%2Fonecli
Code https://github.com/onecli/onecli
Issues 65 https://github.com/onecli/onecli/issues
Pull requests 27 https://github.com/onecli/onecli/pulls
Actions https://github.com/onecli/onecli/actions
Projects https://github.com/onecli/onecli/projects
Security and quality 0 https://github.com/onecli/onecli/security
Insights https://github.com/onecli/onecli/pulse
Code https://github.com/onecli/onecli
Issues https://github.com/onecli/onecli/issues
Pull requests https://github.com/onecli/onecli/pulls
Actions https://github.com/onecli/onecli/actions
Projects https://github.com/onecli/onecli/projects
Security and quality https://github.com/onecli/onecli/security
Insights https://github.com/onecli/onecli/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fonecli%2Fonecli%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fonecli%2Fonecli%2Fissues%2Fnew%2Fchoose
guyb1https://github.com/guyb1
onecli:mainhttps://github.com/onecli/onecli/tree/main
glifocat:fix/oauth-callback-app-url-fallbackhttps://github.com/glifocat/onecli-glifocat/tree/fix/oauth-callback-app-url-fallback
Conversation 4 https://github.com/onecli/onecli/pull/421
Commits 4 https://github.com/onecli/onecli/pull/421/commits
Checks 3 https://github.com/onecli/onecli/pull/421/checks
Files changed https://github.com/onecli/onecli/pull/421/files
Please reload this pagehttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
fix(api): resolve the OAuth callback's app origin from configured APP_URL https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83#top
Show all changes 4 commits https://github.com/onecli/onecli/pull/421/files
cde3f74 fix(api): use getRequestOrigin for the oauth callback redirect origin glifocat Jul 8, 2026 https://github.com/onecli/onecli/pull/421/commits/cde3f743af9e0cbcaa23eb974b98507b3a8d5bc3
75bd422 test(api): callback origin regression tests for APP_URL fallback glifocat Jul 8, 2026 https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
886c1e4 Merge main and reset the implementation guyb1 Jul 25, 2026 https://github.com/onecli/onecli/pull/421/commits/886c1e44d7c0889b92d8c67b5c704e9f2a65d797
8105322 fix(api): resolve the OAuth callback's app origin from configured APP… guyb1 Jul 25, 2026 https://github.com/onecli/onecli/pull/421/commits/8105322cfa02f25bdb82d8d25a147ae4e5cd807f
Clear filters https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Please reload this pagehttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Please reload this pagehttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
Prev https://github.com/onecli/onecli/pull/421/commits/cde3f743af9e0cbcaa23eb974b98507b3a8d5bc3
Next https://github.com/onecli/onecli/pull/421/commits/886c1e44d7c0889b92d8c67b5c704e9f2a65d797
Please reload this pagehttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83
https://github.com/glifocat
glifocathttps://github.com/onecli/onecli/commits?author=glifocat
packages/api/src/routes/apps.test.tshttps://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83#diff-4c74b531c4596d7ff286dd2981d3a741cf8d1a997492d1e68d60a62545917fb7
View file https://github.com/glifocat/onecli-glifocat/blob/75bd42201b28f75e04fc39e4aa2b27f1e1713d83/packages/api/src/routes/apps.test.ts
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/onecli/onecli/pull/421/commits/{{ revealButtonHref }}
https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83#diff-4c74b531c4596d7ff286dd2981d3a741cf8d1a997492d1e68d60a62545917fb7
https://github.com/onecli/onecli/pull/421/commits/75bd42201b28f75e04fc39e4aa2b27f1e1713d83#diff-4c74b531c4596d7ff286dd2981d3a741cf8d1a997492d1e68d60a62545917fb7
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.