Skip to content

Commit

Permalink
use server address instead of localhost
Browse files Browse the repository at this point in the history
there is a bug in node-fetch that requires to don't use localhost
node-fetch/node-fetch#1624
  • Loading branch information
Kikobeats committed May 12, 2023
1 parent 7d73a94 commit 17fdcff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
5 changes: 1 addition & 4 deletions packages/cli/src/util/extension/proxy.ts
Expand Up @@ -8,10 +8,7 @@ import {
import type { Server } from 'http';
import type Client from '../client';

const toHeaders = buildToHeaders({
// @ts-expect-error - `node-fetch` Headers is missing `getAll()`
Headers,
});
const toHeaders = buildToHeaders({ Headers });

export function createProxy(client: Client): Server {
return createServer(async (req, res) => {
Expand Down
20 changes: 8 additions & 12 deletions packages/node/test/unit/dev.test.ts
Expand Up @@ -82,9 +82,8 @@ test('runs an edge function that uses `buffer`', async () => {
throw new Error('Exited. error: ' + JSON.stringify(result.value));
}

const response = await fetch(
`http://localhost:${result.value.port}/api/edge-buffer`
);
const { address, port } = result.value;
const response = await fetch(`http://${address}:${port}/api/edge-buffer`);
expect({
status: response.status,
json: await response.json(),
Expand All @@ -109,9 +108,8 @@ test('runs a mjs endpoint', async () => {
throw new Error('Exited. error: ' + JSON.stringify(result.value));
}

const response = await fetch(
`http://localhost:${result.value.port}/api/hello`
);
const { address, port } = result.value;
const response = await fetch(`http://${address}:${port}/api/hello`);
expect({
status: response.status,
headers: Object.fromEntries(response.headers),
Expand Down Expand Up @@ -142,9 +140,8 @@ test('runs a esm typescript endpoint', async () => {
throw new Error('Exited. error: ' + JSON.stringify(result.value));
}

const response = await fetch(
`http://localhost:${result.value.port}/api/hello`
);
const { address, port } = result.value;
const response = await fetch(`http://${address}:${port}/api/hello`);
expect({
status: response.status,
headers: Object.fromEntries(response.headers),
Expand Down Expand Up @@ -175,9 +172,8 @@ test('allow setting multiple cookies with same name', async () => {
throw new Error(`Exited. error: ${JSON.stringify(result.value)}`);
}

const response = await fetch(
`http://localhost:${result.value.port}/api/hello`
);
const { address, port } = result.value;
const response = await fetch(`http://${address}:${port}/api/hello`);
expect({
status: response.status,
text: await response.text(),
Expand Down

0 comments on commit 17fdcff

Please sign in to comment.