Skip to content

[BUG] setExtraHTTPHeaders ignores CORS in WebKit/FirefoxΒ #19904

Open
@buraksimsekgit

Description

Context:

  • Playwright Version: [1.29.1]
  • Operating System: [Mac OS venture 13.1]
  • Node.js version: [v16.15.1]
  • Browser: [e.g. All, Chromium, Firefox, WebKit]
  • Extra: [any specific details about your environment]

Code Snippet

My code:

test.describe(' E2E test', () => {
  test.only('new user', async ({ schedule, page }) => {
    await page.setExtraHTTPHeaders({ "X-GAT-apiEnv": "stage" });
  `);

})();

Describe the bug

I'm trying to run end-to-end tests on my framework. And I have to define
await page.setExtraHTTPHeaders({ "X-GAT-apiEnv": "stage" }); on my each test as I added above.

My problem is; when I try to run tests against Chromium I'm seeing so many errors when I check the console in the dev tools, and some web elements that need to be shown are not appearing at all.

And these are the some of errors I'm seeing in the console when I check dev tools:

Access to XMLHttpRequest at 'URL' from origin 'URL' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

or

Access to XMLHttpRequest at 'URL' from origin 'URL has been blocked by CORS policy: Request header field x-gat-apienv is not allowed by Access-Control-Allow-Headers in preflight response.

Tests are running quite fine with both Firefox and Webkit, but with Chromium, I can't fix this issue. When I remove that setExtraHTTPHeaders it works fine but we must add it to each test.

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions