From b7adc35669de5555f52d89c5887f96f4a0bb9189 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jun 2024 18:01:34 +0100 Subject: [PATCH] Playwright ensure the BASE_URL is a secure context Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- playwright.config.ts | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/playwright.config.ts b/playwright.config.ts index 458cf98daf0..6f46baae398 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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: { @@ -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", },