Skip to content

Lightpanda: the headless browser designed for AI and automation

add credentials to preflight key for cors

Muki Kiboigo1f9342e92fb7
diff --git a/src/network/CorsGate.zig b/src/network/CorsGate.zig
index 50f1139b0..f76185d47 100644
--- a/src/network/CorsGate.zig
+++ b/src/network/CorsGate.zig
@@ -237,6 +237,7 @@ const CorsKey = struct {
url: []const u8,
origin: []const u8,
method: http.Method,
+ wants_credentials: bool,
// lowercased and sorted.
authored_headers: []const []const u8,
@@ -249,6 +250,8 @@ const CorsKey = struct {
try buf.append(arena, 0);
try buf.appendSlice(arena, @tagName(self.method));
try buf.append(arena, 0);
+ try buf.append(arena, if (self.wants_credentials) 1 else 0);
+ try buf.append(arena, 0);
for (self.authored_headers) |h| {
try buf.appendSlice(arena, h);
@@ -471,6 +474,7 @@ fn fetchThenResume(self: *CorsGate, transfer: *Transfer) !void {
.url = url,
.origin = origin,
.method = transfer.req.method,
+ .wants_credentials = transfer.req.credentials_mode == .include,
.authored_headers = header_names.items,
};
const key = try cors_key.build(transfer.arena.allocator());