Skip to content

Commit b8e7e9a

Browse files
committed
fix: use process.env for VITE_API_URI
1 parent 24101bc commit b8e7e9a

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

src/ui/services/user.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import { UserData } from '../../types/models';
44

55
type SetStateCallback<T> = (value: T | ((prevValue: T) => T)) => void;
66

7-
const baseUrl: string = process.env.VITE_API_URI || location.origin;
8-
7+
const baseUrl = process.env.VITE_API_URI || location.origin;
98
const config = {
109
withCredentials: true,
1110
};

vite.config.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { defineConfig } from 'vite';
1+
import { defineConfig, loadEnv } from 'vite';
22
import react from '@vitejs/plugin-react';
33

4-
export default defineConfig({
5-
build: {
6-
outDir: 'build',
7-
},
8-
server: {
9-
port: 3000,
10-
},
11-
plugins: [react()],
12-
});
4+
export default ({ mode }: { mode: string }) => {
5+
const env = loadEnv(mode, process.cwd(), '');
6+
return defineConfig({
7+
build: {
8+
outDir: 'build',
9+
},
10+
server: {
11+
port: 3000,
12+
},
13+
plugins: [react()],
14+
define: {
15+
'process.env': JSON.stringify(env),
16+
},
17+
});
18+
};

0 commit comments

Comments
 (0)