Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Miniflare 3] Use localhost instead of 127.0.0.1 for loopback hostname #615

Merged
merged 1 commit into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/miniflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,16 +668,16 @@ export class Miniflare {
};

#startLoopbackServer(
port: string | number,
hostname?: string
port: number,
hostname: string
): Promise<StoppableServer> {
return new Promise((resolve) => {
const server = stoppable(
http.createServer(this.#handleLoopback),
/* grace */ 0
);
server.on("upgrade", this.#handleLoopbackUpgrade);
server.listen(port as any, hostname, () => resolve(server));
server.listen(port, hostname, () => resolve(server));
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/miniflare/src/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export class Runtime {
// (e.g. "streams_enable_constructors"), see https://github.com/cloudflare/workerd/pull/21
"--experimental",
`--socket-addr=${SOCKET_ENTRY}=${this.opts.entryHost}:${this.opts.entryPort}`,
`--external-addr=${SERVICE_LOOPBACK}=127.0.0.1:${this.opts.loopbackPort}`,
`--external-addr=${SERVICE_LOOPBACK}=localhost:${this.opts.loopbackPort}`,
// Configure extra pipe for receiving control messages (e.g. when ready)
"--control-fd=3",
// Read config from stdin
Expand Down