From e7e6ee3ab67dfdbd3467715de5a538cc6bbcfc73 Mon Sep 17 00:00:00 2001 From: Ronen Mars Date: Tue, 28 Oct 2025 08:30:18 +0200 Subject: [PATCH 1/2] fix: run with domain configuration --- README.md | 6 ++++++ playwright.config.ts | 2 +- vite.config.ts | 9 +++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e33e901e7e..a76fc8ea87 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,12 @@ Create a `.env` file in the root of the project directory and add the necessary - Description: Used for running E2E tests when authentication is enabled on the backend. This JWT token allows the test runner to authenticate and access the application during testing. - Example: TESTS_JWT_AUTH_TOKEN=your_jwt_auth_token_for_e2e_tests +`VITE_DISABLE_MKCERT_SSL` + +- Default: None (SSL certificates are enabled by default) +- Description: When set to "true", disables automatic SSL certificate generation via mkcert. This forces the development server to use HTTP instead of HTTPS and restricts SSL certificates to localhost only. +- Example: VITE_DISABLE_MKCERT_SSL=true + **Note:** These environment variables are optional. The application will use default values or fall back to certain behaviors if these variables are not set. However, setting them allows for greater customization and functionality, especially in different deployment environments or when running tests. ### Running the Project 🏃 diff --git a/playwright.config.ts b/playwright.config.ts index dc379660cb..59475ac86e 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -67,7 +67,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: "http://localhost:8000", + baseURL: "https://localhost:8000", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on", diff --git a/vite.config.ts b/vite.config.ts index e084f27f18..1115f04879 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -86,8 +86,13 @@ export default defineConfig({ include: ["tailwind-config", "apexcharts"], }, plugins: [ - ...(process.env.VITE_LOCAL_SSL_CERT === "true" ? [mkcert()] : []), react(), + mkcert({ + hosts: + process.env.VITE_DISABLE_MKCERT_SSL === "true" && process.env.VITE_APP_DOMAIN + ? ["localhost"] + : ["localhost", process.env.VITE_APP_DOMAIN].filter(Boolean), + }), ViteEjsPlugin((viteConfig) => ({ env: viteConfig.env, })), @@ -177,7 +182,7 @@ export default defineConfig({ }, }, server: { - host: process.env.VITE_APP_DOMAIN ? JSON.stringify(process.env.VITE_APP_DOMAIN) : true, + host: process.env.VITE_APP_DOMAIN ? "0.0.0.0" : true, port: process.env.VITE_LOCAL_PORT ? Number(process.env.VITE_LOCAL_PORT) : 8000, strictPort: true, }, From c554fd485b2fef1efa63db358e187814c9d953f0 Mon Sep 17 00:00:00 2001 From: Ronen Mars Date: Tue, 28 Oct 2025 10:07:48 +0200 Subject: [PATCH 2/2] fix: e2e tests after the config change --- mkcert.util.ts | 11 +++++++++++ playwright.config.ts | 2 +- tsconfig.node.json | 6 +++--- vite.config.ts | 8 ++------ 4 files changed, 17 insertions(+), 10 deletions(-) create mode 100644 mkcert.util.ts diff --git a/mkcert.util.ts b/mkcert.util.ts new file mode 100644 index 0000000000..e231233823 --- /dev/null +++ b/mkcert.util.ts @@ -0,0 +1,11 @@ +import { MkcertPluginOptions } from "vite-plugin-mkcert"; + +export const securedDomainConfigured = process.env.VITE_APP_DOMAIN && process.env.VITE_ENABLE_MKCERT_SSL; + +export const securedDomainHosts = securedDomainConfigured + ? ["localhost", process.env.VITE_APP_DOMAIN].filter(Boolean) + : ["localhost"]; + +export const mkcertConfig: MkcertPluginOptions = { + hosts: securedDomainHosts as string[], +}; diff --git a/playwright.config.ts b/playwright.config.ts index 59475ac86e..dc379660cb 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -67,7 +67,7 @@ export default defineConfig({ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: "https://localhost:8000", + baseURL: "http://localhost:8000", /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on", diff --git a/tsconfig.node.json b/tsconfig.node.json index 1fd88fdaa2..bb1e5f09b1 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -4,8 +4,8 @@ "skipLibCheck": true, "module": "ESNext", "moduleResolution": "bundler", - "allowSyntheticDefaultImports": true + "allowSyntheticDefaultImports": true, + "strict": true }, - "include": ["vite.config.ts", - "fixReactVirtualized.ts"] + "include": ["vite.config.ts","fixReactVirtualized.ts","mkcert.util.ts"] } diff --git a/vite.config.ts b/vite.config.ts index 1115f04879..385c7dd986 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,6 +9,7 @@ import { viteStaticCopy } from "vite-plugin-static-copy"; import svgr from "vite-plugin-svgr"; import { reactVirtualized } from "./fixReactVirtualized"; +import { securedDomainConfigured, mkcertConfig } from "./mkcert.util"; dotenv.config(); @@ -87,12 +88,7 @@ export default defineConfig({ }, plugins: [ react(), - mkcert({ - hosts: - process.env.VITE_DISABLE_MKCERT_SSL === "true" && process.env.VITE_APP_DOMAIN - ? ["localhost"] - : ["localhost", process.env.VITE_APP_DOMAIN].filter(Boolean), - }), + ...(securedDomainConfigured ? [mkcert(mkcertConfig)] : []), ViteEjsPlugin((viteConfig) => ({ env: viteConfig.env, })),