host is a forbidden header

This commit is contained in:
Moon Man 2023-12-31 06:59:38 -05:00
parent 16f42e5cd9
commit cde8a2620a
1 changed files with 7 additions and 3 deletions

View File

@ -19,9 +19,10 @@ export interface SignedInit {
// TODO: Handle redirects.
export const signedFetch = async (url: string, init: RequestInit, signedInit: SignedInit): Promise<globalThis.Response> => {
const now = new Date().toUTCString();
const signedHeaders: HeadersInit = [
["Host", new URL(url).host],
["Date", new Date().toUTCString()]
["Date", now]
];
const headerNames = ["(request-target)", "host", "date"];
@ -52,7 +53,10 @@ export const signedFetch = async (url: string, init: RequestInit, signedInit: Si
const signature = signer.sign({
url,
method: init.method as string,
headers: signedHeaders
headers: [
["Host", new URL(url).host],
...signedHeaders
]
});
const newHeaders: HeadersInit =