Fix AllowedHost to store parsed host instead of raw input

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 <[email protected]>
This commit is contained in:
Cursor AgentandJulius Marminge committed 2026-03-17 20:08:37 +00:00
1 parent 11091bf337
commit ec7629b2b1
1 file changed
+7 -1
+7 -1
View File
@@ -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(