How to fix net::ERR_INVALID_AUTH_CREDENTIALS in Playwright?

Playwright

This means HTTP auth credentials are missing or incorrect.

Set valid httpCredentials when creating the browser context.

const context = await browser.newContext({
  httpCredentials: {
    username: process.env.BASIC_AUTH_USER,
    password: process.env.BASIC_AUTH_PASS,
  },
});

const page = await context.newPage();
await page.goto('https://staging.example.com');

Confirm credentials match the environment (staging vs production) and are not empty.