Skip to content

Commit 16f8db8

Browse files
authored
Forbid Proxy-* and Sec-* headers via TypeScript (#2198)
# Test Plan ```ts createHttpTransport({ headers: { 'Proxy-Foo': 'Bar', // ERROR 'proxy-foo': 'Bar', // ERROR 'PROXY-FOO': 'Bar', // ERROR 'Sec-Foo': 'Bar', // ERROR 'sec-foo': 'Bar', // ERROR 'SEC-FOO': 'Bar', // ERROR }, }); ```
1 parent 356279e commit 16f8db8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/rpc-transport-http/src/http-transport-headers.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ type ForbiddenHeaders =
2929
| 'Keep-Alive'
3030
| 'Origin'
3131
| 'Permissions-Policy'
32-
// No currently available Typescript technique allows you to match on a prefix.
33-
// | 'Proxy-'
34-
// | 'Sec-'
32+
| `Proxy-${string}`
33+
| `Sec-${string}`
3534
| 'Referer'
3635
| 'TE'
3736
| 'Trailer'
@@ -61,9 +60,9 @@ const FORBIDDEN_HEADERS: Record<string, boolean> = {
6160
'keep-alive': true,
6261
origin: true,
6362
'permissions-policy': true,
64-
// No currently available Typescript technique allows you to match on a prefix.
65-
// 'proxy-':true,
66-
// 'sec-':true,
63+
// Prefix matching is implemented in code, below.
64+
// 'proxy-': true,
65+
// 'sec-': true,
6766
referer: true,
6867
te: true,
6968
trailer: true,

0 commit comments

Comments
 (0)