Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 🏃
Expand Down
11 changes: 11 additions & 0 deletions mkcert.util.ts
Original file line number Diff line number Diff line change
@@ -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[],
};
6 changes: 3 additions & 3 deletions tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
5 changes: 3 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -86,8 +87,8 @@ export default defineConfig({
include: ["tailwind-config", "apexcharts"],
},
plugins: [
...(process.env.VITE_LOCAL_SSL_CERT === "true" ? [mkcert()] : []),
react(),
...(securedDomainConfigured ? [mkcert(mkcertConfig)] : []),
ViteEjsPlugin((viteConfig) => ({
env: viteConfig.env,
})),
Expand Down Expand Up @@ -177,7 +178,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,
},
Expand Down