From ec7629b2b19db6b83bc3570e39119c5c1441e881 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 17 Mar 2026 20:08:37 +0000 Subject: [PATCH] Fix AllowedHost to store parsed host instead of raw input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Store `parsed.host` from the WHATWG URL parser instead of the raw lowercased input string. This ensures the stored allowlist entries match what `normalizeRequestHost` produces at request time: - Trailing slashes are stripped (e.g. "app.example/" → "app.example") - Default HTTP ports are stripped (e.g. "app.example:80" → "app.example") Both normalizations already happen in `normalizeRequestHost` via `new URL(...).host`, so applying the same transform at storage time keeps the two sides consistent. Co-authored-by: Julius Marminge --- apps/server/src/main.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts index 8420d7ca1f..4fc3f3c595 100644 --- a/apps/server/src/main.ts +++ b/apps/server/src/main.ts @@ -74,7 +74,13 @@ const AllowedHost = Schema.Trim.pipe( { identifier: "AllowedHost" }, ), ), - Schema.decodeTo(Schema.String, SchemaTransformation.toLowerCase()), + Schema.decodeTo( + Schema.String, + SchemaTransformation.transform({ + decode: (input) => new URL(`http://${input}`).host, + encode: (input) => input, + }), + ), ); const AllowedHostsCsv = Schema.String.pipe(