The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
feat(vite): add HTTPS support with configurable SSL (#8585)
Antoine Moreaux3f98c2ddbe80
diff --git a/packages/twenty-front/.env.example b/packages/twenty-front/.env.exampleindex 345d0fb92ad..1f9a51b3306 100644--- a/packages/twenty-front/.env.example+++ b/packages/twenty-front/.env.example@@ -5,4 +5,7 @@ GENERATE_SOURCEMAP=false# REACT_APP_PORT=3001# CHROMATIC_PROJECT_TOKEN=# VITE_DISABLE_TYPESCRIPT_CHECKER=true-# VITE_DISABLE_ESLINT_CHECKER=true\ No newline at end of file+# VITE_DISABLE_ESLINT_CHECKER=true+# VITE_ENABLE_SSL=false+# SSL_KEY_PATH="./certs/your-cert.key"+# SSL_CERT_PATH="./certs/your-cert.crt"\ No newline at end of filediff --git a/packages/twenty-front/vite.config.ts b/packages/twenty-front/vite.config.tsindex c631a60e55a..eec22a826b3 100644--- a/packages/twenty-front/vite.config.ts+++ b/packages/twenty-front/vite.config.ts@@ -3,6 +3,7 @@ import { isNonEmptyString } from '@sniptt/guards';import react from '@vitejs/plugin-react-swc';import wyw from '@wyw-in-js/vite';import path from 'path';+import fs from 'fs';import { defineConfig, loadEnv, searchForWorkspaceRoot } from 'vite';import checker from 'vite-plugin-checker';import svgr from 'vite-plugin-svgr';@@ -18,6 +19,7 @@ export default defineConfig(({ command, mode }) => {VITE_BUILD_SOURCEMAP,VITE_DISABLE_TYPESCRIPT_CHECKER,VITE_DISABLE_ESLINT_CHECKER,+ VITE_ENABLE_SSL,REACT_APP_PORT,} = env;@@ -62,13 +64,27 @@ export default defineConfig(({ command, mode }) => {};}+ if (VITE_ENABLE_SSL && (!env.SSL_KEY_PATH || !env.SSL_CERT_PATH)) {+ throw new Error(+ 'to use https SSL_KEY_PATH and SSL_CERT_PATH must be both defined',+ );+ }+return {root: __dirname,cacheDir: '../../node_modules/.vite/packages/twenty-front',server: {- port,- host: 'localhost',+ port: port,+ protocol: VITE_ENABLE_SSL ? 'https' : 'http',+ ...(VITE_ENABLE_SSL+ ? {+ https: {+ key: fs.readFileSync(env.SSL_KEY_PATH),+ cert: fs.readFileSync(env.SSL_CERT_PATH),+ },+ }+ : {}),fs: {allow: [searchForWorkspaceRoot(process.cwd()),