Search code examples
javascriptgoogle-chrome-extensionchrome-extension-manifest-v3

modify set-cookie header chrome extenstion in manifest v3


I have a use case where my old extension contains code that will add ; SameSite=None; Secure to the set-cookie header for iframe's. like the below code `

 event.responseHeaders.forEach((header) => {
      if (header.name.toLowerCase() === "set-cookie") {
        header.value = header.value + "; SameSite=None; Secure"
      }
    });

`

I need an equivalent in manfifest v3 I have tried

{
      id: 2,
      priority: 1,
      action: {
        type: "modifyHeaders",
        responseHeaders: [
          {
            header: "Set-Cookie",
            operation: "append",
            value: "'SameSite=None; Secure'",
          },
        ],
      },
      condition: {
        urlFilter: "*",
        resourceTypes: ["sub_frame"],
      },
    },

And it is not doing anything


Solution

  • It's not implemented: https://crbug.com/1254637.

    • The append operation for responseHeaders just adds a new header with this name and value.

    • The append operation for requestHeaders appends the value via a delimiter in supported headers. Implemented since Chrome 108, previously an error was shown.