From 3385e45a95b36fc888f71c7959bb92906eebb7e9 Mon Sep 17 00:00:00 2001 From: Marcos Candeia Date: Fri, 19 Jul 2024 17:06:29 -0300 Subject: [PATCH] Fix passing host to warp client Signed-off-by: Marcos Candeia --- deno.json | 2 +- handlers.client.ts | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/deno.json b/deno.json index 708bdef..2c21401 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@deco/warp", - "version": "0.2.7", + "version": "0.2.8", "exports": "./mod.ts", "tasks": { "check": "deno fmt && deno lint && deno check mod.ts" diff --git a/handlers.client.ts b/handlers.client.ts index 0199335..5d5d766 100644 --- a/handlers.client.ts +++ b/handlers.client.ts @@ -208,13 +208,18 @@ async function doFetch( // Read from the stream const signal = clientCh.signal; try { - const response = await fetch(new URL(request.url, state.localAddr), { - ...state.client ? { client: state.client } : {}, - method: request.method, - headers: request.headers, - body: request.body, - signal, - }); + const response = await fetch( + new URL(request.url, state.localAddr), + { + ...state.client ? { client: state.client } : {}, + method: request.method, + headers: state.client + ? { ...request.headers, host: request.domain } + : request.headers, + body: request.body, + signal, + }, + ); await clientCh.send({ type: "response-start", id: request.id,