diff --git a/.env.declaration b/.env.declaration new file mode 100644 index 00000000..4f14f613 --- /dev/null +++ b/.env.declaration @@ -0,0 +1,3 @@ +DAPLA_TEAM_API_URL= +DAPLA_TEAM_API_CLUSTER_URL= +PORT=8080 \ No newline at end of file diff --git a/package.json b/package.json index 065c3198..f46da9ca 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,8 @@ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", "lint:fix": "eslint ./src --ext .jsx,.js,.ts,.tsx --quiet --fix --ignore-path ./.gitignore", "lint:format": "prettier --loglevel warn --write \"./**/*.{js,jsx,ts,tsx,css,md,json}\" ", - "preview": "vite preview" + "preview": "vite preview", + "prepare": "npx vite-envs update-types" }, "dependencies": { "@emotion/react": "^11.11.4", diff --git a/server.js b/server.js index 89e4e7a8..ebe5e4ab 100644 --- a/server.js +++ b/server.js @@ -7,7 +7,7 @@ import proxy from 'express-http-proxy' const app = express() const PORT = process.env.PORT || 3000 // use cluster URL if available -const DAPLA_TEAM_API_URL = process.env.DAPLA_TEAM_API_CLUSTER_URL || 'https://dapla-team-api-v2.staging-bip-app.ssb.no' +const DAPLA_TEAM_API_URL = process.env.DAPLA_TEAM_API_CLUSTER_URL || "https://dapla-team-api-v2.staging-bip-app.ssb.no" // Proxy, note this middleware must be place before all else.. THIS TOOK ME 3 HOURS TO FIGURE OUT! TODO: Remove comment app.use( diff --git a/src/utils/utils.ts b/src/utils/utils.ts index efd0e250..9493c960 100644 --- a/src/utils/utils.ts +++ b/src/utils/utils.ts @@ -1,7 +1,7 @@ // https://vitejs.dev/config/server-options.html // https://github.com/garronej/vite-envs -export const DAPLA_TEAM_API_URL = `http://localhost:${import.meta.env.PORT.trim()}/api` +export const DAPLA_TEAM_API_URL = `http://localhost:${import.meta.env.PORT}/api` export const getGroupType = (groupName: string) => { const match = groupName.match(/(managers|developers|data-admins|support|consumers)$/) diff --git a/vite.config.ts b/vite.config.ts index 4877287b..c224cadf 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,7 +7,7 @@ export default defineConfig({ plugins: [ react(), viteEnvs({ - declarationFile: '.env.local', + declarationFile: '.env.declaration', }), ], })