@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 03:37 UTC

main
ts 14 lines 604 Bytes
Raw
1 import * as Option from "effect/Option";
2 import { HttpServerRequest } from "effect/http";
3
4 /**
5 * `HttpServerRequest.toURL` that honors `X-Forwarded-Proto: https`. Effect 4.1
6 * stopped reading it, but TLS-terminating proxies in front of the server
7 * (Tailscale Serve, tunnels) rely on it for OAuth, DPoP and pairing URLs.
8 */
9 export const requestUrl = (request: HttpServerRequest.HttpServerRequest): Option.Option<URL> =>
10 HttpServerRequest.toURL(
11 request.headers["x-forwarded-proto"] === "https" && request.protocol !== "https"
12 ? request.modify({ protocol: "https" })
13 : request,
14 );