From 3114c458d85a35969211e9667e802b25308563d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Ayg=C3=BCn?= Date: Wed, 25 Feb 2026 12:46:26 +0000 Subject: [PATCH 1/2] fix: new Request() will not work without a host The examples in the docs use bare URLs with the `Request` constructor like `new Request('/request-to-handle')` but in Node, this constructor requires a full URL with a host, otherwise a `TypeError: Failed to parse URL from /request-to-handle` will be thrown. But this is not a complete fix, we need to explain where the `HOST_NAME` constant will come from and what it should contain. Opening this PR to start the discussion. --- docs/guide/api-environment-frameworks.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/api-environment-frameworks.md b/docs/guide/api-environment-frameworks.md index 089ce3f3dca1a6..44802494bba156 100644 --- a/docs/guide/api-environment-frameworks.md +++ b/docs/guide/api-environment-frameworks.md @@ -151,7 +151,7 @@ const server = await createServer({ // Any consumer of the environment API can now call `dispatchFetch` if (isFetchableDevEnvironment(server.environments.custom)) { const response: Response = await server.environments.custom.dispatchFetch( - new Request('/request-to-handle'), + new Request(HOST_NAME + '/request-to-handle'), ) } ``` @@ -196,7 +196,7 @@ if (ssrEnvironment instanceof CustomDevEnvironment) { // virtual:entrypoint const { createHandler } = await import('./entrypoint.js') const handler = createHandler(input) -const response = handler(new Request('/')) +const response = handler(new Request(HOST_NAME + '/')) // ------------------------------------- // ./entrypoint.js @@ -266,7 +266,7 @@ if (ssrEnvironment instanceof RunnableDevEnvironment) { throw new Error(`Unsupported runtime for ${ssrEnvironment.name}`) } -const req = new Request('/') +const req = new Request(HOST_NAME + '/') const uniqueId = 'a-unique-id' ssrEnvironment.send('request', serialize({ req, uniqueId })) @@ -290,7 +290,7 @@ import.meta.hot.on('request', (data) => { import.meta.hot.send('response', serialize({ res: res, uniqueId })) }) -const response = handler(new Request('/')) +const response = handler(new Request(HOST_NAME + '/')) // ------------------------------------- // ./entrypoint.js From d094c0004ee54fb18d6b0a1fac07e9adb8baf338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fatih=20Ayg=C3=BCn?= Date: Thu, 26 Feb 2026 13:48:42 +0000 Subject: [PATCH 2/2] fix: change Request URLs to example.com --- docs/guide/api-environment-frameworks.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/api-environment-frameworks.md b/docs/guide/api-environment-frameworks.md index 44802494bba156..2f413092c7b7d5 100644 --- a/docs/guide/api-environment-frameworks.md +++ b/docs/guide/api-environment-frameworks.md @@ -151,7 +151,7 @@ const server = await createServer({ // Any consumer of the environment API can now call `dispatchFetch` if (isFetchableDevEnvironment(server.environments.custom)) { const response: Response = await server.environments.custom.dispatchFetch( - new Request(HOST_NAME + '/request-to-handle'), + new Request('http://example.com/request-to-handle'), ) } ``` @@ -196,7 +196,7 @@ if (ssrEnvironment instanceof CustomDevEnvironment) { // virtual:entrypoint const { createHandler } = await import('./entrypoint.js') const handler = createHandler(input) -const response = handler(new Request(HOST_NAME + '/')) +const response = handler(new Request('http://example.com/')) // ------------------------------------- // ./entrypoint.js @@ -266,7 +266,7 @@ if (ssrEnvironment instanceof RunnableDevEnvironment) { throw new Error(`Unsupported runtime for ${ssrEnvironment.name}`) } -const req = new Request(HOST_NAME + '/') +const req = new Request('http://example.com/') const uniqueId = 'a-unique-id' ssrEnvironment.send('request', serialize({ req, uniqueId })) @@ -290,7 +290,7 @@ import.meta.hot.on('request', (data) => { import.meta.hot.send('response', serialize({ res: res, uniqueId })) }) -const response = handler(new Request(HOST_NAME + '/')) +const response = handler(new Request('http://example.com/')) // ------------------------------------- // ./entrypoint.js