Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Playwright ensure the BASE_URL is a secure context
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Jun 26, 2024
1 parent 4bf8766 commit b7adc35
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,16 @@ limitations under the License.

import { defineConfig } from "@playwright/test";

const baseURL = process.env["BASE_URL"] ?? "http://localhost:8080";
let baseURL = "http://localhost:8080";

const extraLaunchArgs: string[] = [];
if (process.env["BASE_URL"]) {
baseURL = process.env["BASE_URL"];
// We need to use a different headless mode to allow insecure origins
// https://github.com/microsoft/playwright/issues/22944
extraLaunchArgs.push("--headless=new");
extraLaunchArgs.push(`--unsafely-treat-insecure-origin-as-secure=${baseURL}`);
}

export default defineConfig({
use: {
Expand All @@ -26,7 +35,12 @@ export default defineConfig({
baseURL,
permissions: ["clipboard-write", "clipboard-read", "microphone"],
launchOptions: {
args: ["--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--mute-audio"],
args: [
"--use-fake-ui-for-media-stream",
"--use-fake-device-for-media-stream",
"--mute-audio",
...extraLaunchArgs,
],
},
trace: "on-first-retry",
},
Expand Down

0 comments on commit b7adc35

Please sign in to comment.