(request: Request)
| 9 | |
| 10 | /** The origin a request came from: the browser `Origin`, else the proxy host. */ |
| 11 | export const originOf = (request: Request): string | null => { |
| 12 | const explicit = request.headers.get("origin"); |
| 13 | if (explicit) return explicit; |
| 14 | const host = request.headers.get("x-forwarded-host") ?? request.headers.get("host"); |
| 15 | if (!host) return null; |
| 16 | const proto = request.headers.get("x-forwarded-proto") ?? "https"; |
| 17 | return `${proto}://${host}`; |
| 18 | }; |
| 19 | |
| 20 | /** Actionable replacement for "Invalid origin". */ |
| 21 | export const invalidOriginHelp = (requestOrigin: string | null, webBaseUrl: string): string => |
no test coverage detected