Skip to content

Commit

Permalink
chore: fix invalid env variables load in vite config
Browse files Browse the repository at this point in the history
  • Loading branch information
brunotot committed Aug 29, 2024
1 parent 2d2bce3 commit 1345cfb
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,26 +138,26 @@
},
{
"name": "backend > build",
"runtimeArgs": ["run", "--filter", "backend", "build"],
"runtimeArgs": ["run", "build", "--prefix", "packages/backend"],
"presentation": { "group": "3" },
// Defaults below
"runtimeVersion": "21.7.0",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeExecutable": "npm",
"console": "integratedTerminal",
"outputCapture": "std",
"autoAttachChildProcesses": false
},
{
"name": "frontend > dev",
"runtimeArgs": ["run", "--filter", "frontend", "dev"],
"runtimeArgs": ["run", "dev", "--prefix", "packages/frontend"],
"presentation": { "group": "4" },
// Defaults below
"runtimeVersion": "21.7.0",
"type": "node",
"request": "launch",
"runtimeExecutable": "pnpm",
"runtimeExecutable": "npm",
"console": "integratedTerminal",
"outputCapture": "std",
"autoAttachChildProcesses": false
Expand Down
10 changes: 9 additions & 1 deletion packages/frontend/src/setup/apiClient.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { initClient } from "@ts-rest/core";
import { contracts } from "@org/shared";

console.log(import.meta.env);

const API_CLIENT_URL = import.meta.env.VITE_API_CLIENT_URL;

if (!API_CLIENT_URL) {
throw new Error("Env variable: 'API_CLIENT_URL' is not defined");
}

export const apiClient = initClient(contracts, {
baseUrl: import.meta.env.VITE_API_CLIENT_URL,
baseUrl: API_CLIENT_URL,
baseHeaders: {},
});
1 change: 1 addition & 0 deletions packages/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { defineConfig } from "vite";

// https://vitejs.dev/config/
export default defineConfig({
envDir: path.resolve(__dirname),
root: path.resolve(__dirname, "src"),
build: {
outDir: path.resolve(__dirname, "dist"),
Expand Down

0 comments on commit 1345cfb

Please sign in to comment.