Lightpanda: the headless browser designed for AI and automation
use experimental features flag instead of obey cors
Muki Kiboigo15d27902ba1f
diff --git a/src/Config.zig b/src/Config.zigindex c9f215b7a..c5d1fa360 100644--- a/src/Config.zig+++ b/src/Config.zig@@ -244,10 +244,13 @@ pub const LoadResources = packed struct(u4) {stylesheet: bool = false,};+pub const ExperimentalFeatures = packed struct(u1) {+ cors: bool = false,+};+/// Common CLI args.const CommonOptions = .{.{ .name = "obey_robots", .type = bool },- .{ .name = "obey_cors", .type = bool },.{ .name = "proxy_bearer_token", .type = ?[:0]const u8 },.{ .name = "http_proxy", .type = ?[:0]const u8 },.{ .name = "http_max_concurrent", .type = ?u8 },@@ -281,6 +284,7 @@ const CommonOptions = .{.{ .name = "disable_subframes", .type = bool, .deprecated = "subframes are now disabled by default, use \"--load-resources iframe\" to enable" },.{ .name = "disable_workers", .type = bool, .deprecated = "workers are now disabled by default, use \"--load-resources worker\" to enable" },.{ .name = "enable_external_stylesheets", .type = bool, .deprecated = "use \"--load-resources stylesheet\" to enable" },+ .{ .name = "experimental_features", .type = ExperimentalFeatures, .default = ExperimentalFeatures{} },.{ .name = "load_resources", .type = LoadResources, .default = LoadResources{} },.{ .name = "v8_flags_unsafe", .type = ?[]const u8 },.{ .name = "v8_max_heap_mb", .type = ?u32 },@@ -556,9 +560,9 @@ pub fn httpVersion(self: *const Config) HttpVersion {};}-pub fn obeyCors(self: *const Config) bool {+pub fn experimentalFeatures(self: *const Config) ExperimentalFeatures {return switch (self.mode) {- inline .serve, .fetch, .mcp, .agent => |opts| opts.obey_cors,+ inline .serve, .fetch, .mcp, .agent => |opts| opts.experimental_features,else => unreachable,};}diff --git a/src/help.zon b/src/help.zonindex 3451600e4..90308e9b6 100644--- a/src/help.zon+++ b/src/help.zon@@ -359,6 +359,14 @@\\ --cookie-jar <PATH>\\ Path to a JSON file to save cookies to on exit (write-only).\\ Defaults to no cookie saving.+ \\ --experimental-features <FEATURE>+ \\ Enable an experimental, unstable feature. Can be passed multiple times.+ \\ Behavior may change or be removed without notice.+ \\ Defaults to none enabled.+ \\ Allowed values:+ \\ cors Obey CORS (cross-origin resource sharing) checks+ \\ on fetch/XHR requests instead of allowing them+ \\ unconditionally.\\ --load-resources <RESOURCE>\\ Sub-resource to actually request. Can be passed multiple times.\\ Defaults to requesting none of them.@@ -453,9 +461,6 @@\\ --obey-robots\\ Fetches and obeys robots.txt of the target page.\\ Defaults to false.- \\ --obey-cors- \\ Obeys CORS rules, executing preflights as needed.- \\ Defaults to false.\\ --proxy-bearer-token <TOKEN>\\ Token sent for bearer authentication with the proxy:\\ Proxy-Authorization: Bearer <token>.diff --git a/src/network/HttpClient.zig b/src/network/HttpClient.zigindex 701ee075f..ba367ca56 100644--- a/src/network/HttpClient.zig+++ b/src/network/HttpClient.zig@@ -232,7 +232,7 @@ pub fn init(self: *Client, app: *lp.App) !void {.serve_mode = config.mode == .serve,.obey_robots = config.obeyRobots(),.http_version = config.httpVersion(),- .obey_cors = config.obeyCors(),+ .obey_cors = config.experimentalFeatures().cors,.robots = .{.network = network,.single_flight = .init(allocator),