host is a forbidden header
This commit is contained in:
parent
16f42e5cd9
commit
cde8a2620a
10
src/net.ts
10
src/net.ts
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue