Repository navigation
Conversation
Behind a proxy that ends TLS, such as Railway's edge, tailscale serve or the HTTPS reverse proxy the self-host guide recommends, the native host reaches workerd over plain HTTP. ReverseProxy's Rewrite removes the proxy's X-Forwarded-Proto, so HttpServerRequest.toURL derives http://<host>. The dashboard batch's same-origin check then refuses the browser's Origin: https://<host> with an empty 403, and every page that batches its reads shows "Unable to complete this request". When BETTER_AUTH_URL is an https origin, the host now sets X-Forwarded-Proto: https on every request it forwards to workerd. The scheme comes from the configured origin, never from the client: Rewrite still removes any X-Forwarded-Proto the client sent. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Fixes #2199.
Behind a proxy that ends TLS (Railway's edge,
tailscale serve, or the HTTPS reverse proxy the self-host README recommends), everyPOST /api/dashboard/batchreturns an empty 403. Pages that batch their reads then show "Unable to complete this request". This affects self-host from 2.0.0-beta.9 on.Cause
The native host reaches workerd over plain HTTP.
httputil.ReverseProxyremoves the incomingX-Forwarded-*headers beforeRewriteruns, so the product'sHttpServerRequest.toURLbuildshttp://<host>, andsameOrigininpackages/dashboard-start/src/implementation/batch-host.tsrefuses the browser'sOrigin: https://<host>.SetXForwarded()would not help: it takes the scheme from the host's own plain-HTTP connection.Fix
When
BETTER_AUTH_URLishttps://…, the host setsX-Forwarded-Proto: httpson every request it forwards to workerd. The scheme comes from configuration, never from the client: a client-sentX-Forwarded-Protois still dropped. The server-rendered pages that derive their origin the same way (document.ts,in-process.ts) get the right scheme too.#2246 proposed the same approach and was closed by its author without comment. If you would rather compare the batch
OriginwithBETTER_AUTH_URL's origin inbatch-host.ts, as the other hosted origin checks do, I'm happy to switch.One behavior change: a server configured for
https://but opened over plainhttp://now gets 403 on batches. Sign-in already fails in that setup.Tested
gofmt -l,go vetandgo test ./...inapps/hosted/self-host/nativepass. The newTestProxyForwardsTheSchemeOfTheConfiguredOriginfails without the change.BETTER_AUTH_URL=https://exec-test.example:4788:POST /api/dashboard/batchwith the instance's ownhttps://Origin gets 403 from the official image and 400 from the patched one (origin accepted, empty batch refused). A foreign Origin, a missing Origin and atext/plainbody still get 403./healthand unauthenticated/mcpare unchanged.tailscale serveon our self-host since 2026-10-10: the same probe returns 400, and a foreign Origin 403.🤖 Generated with Claude Code