diff options
Diffstat (limited to '')
-rw-r--r-- | src/bun.js/api/server.zig | 26 | ||||
-rw-r--r-- | src/bun.js/javascript.zig | 15 |
2 files changed, 28 insertions, 13 deletions
diff --git a/src/bun.js/api/server.zig b/src/bun.js/api/server.zig index 10ef5e825..c3501019a 100644 --- a/src/bun.js/api/server.zig +++ b/src/bun.js/api/server.zig @@ -96,7 +96,7 @@ const linux = std.os.linux; pub const ServerConfig = struct { port: u16 = 0, - hostname: [*:0]const u8 = "0.0.0.0", + hostname: [*:0]const u8 = "localhost", // TODO: use webkit URL parser instead of bun's base_url: URL = URL{}, @@ -2405,19 +2405,19 @@ pub fn NewServer(comptime ssl_enabled_: bool, comptime debug_mode_: bool) type { } const hostname = bun.span(this.config.hostname); + // When "localhost" is specified, we omit the hostname entirely + // Otherwise, "curl http://localhost:3000" doesn't actually work due to IPV6 vs IPV4 issues + // This prints a spurious log si_destination_compare on macOS but only when debugger is connected + const host: [*:0]const u8 = if (hostname.len == 0 or (!ssl_enabled and strings.eqlComptime(hostname, "localhost"))) + "" + else + this.config.hostname; - if (!(hostname.len == 0 or strings.eqlComptime(hostname, "0.0.0.0"))) { - this.app.listenWithConfig(*ThisServer, this, onListen, .{ - .port = this.config.port, - .options = 0, - }); - } else { - this.app.listenWithConfig(*ThisServer, this, onListen, .{ - .port = this.config.port, - .host = this.config.hostname, - .options = 0, - }); - } + this.app.listenWithConfig(*ThisServer, this, onListen, .{ + .port = this.config.port, + .host = host, + .options = 0, + }); } }; } diff --git a/src/bun.js/javascript.zig b/src/bun.js/javascript.zig index d52a864a9..eb3a5a455 100644 --- a/src/bun.js/javascript.zig +++ b/src/bun.js/javascript.zig @@ -350,7 +350,22 @@ pub const VirtualMachine = struct { has_any_macro_remappings: bool = false, is_from_devserver: bool = false, has_enabled_macro_mode: bool = false, + + /// The arguments used to launch the process _after_ the script name and bun and any flags applied to Bun + /// "bun run foo --bar" + /// ["--bar"] + /// "bun run foo baz --bar" + /// ["baz", "--bar"] + /// "bun run foo + /// [] + /// "bun foo --bar" + /// ["--bar"] + /// "bun foo baz --bar" + /// ["baz", "--bar"] + /// "bun foo + /// [] argv: []const []const u8 = &[_][]const u8{"bun"}, + global_api_constructors: [GlobalConstructors.len]JSC.JSValue = undefined, origin_timer: std.time.Timer = undefined, |