-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
34 lines (32 loc) · 1.2 KB
/
vite.config.ts
File metadata and controls
34 lines (32 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { defineConfig, loadEnv } from "vite";
import react from "@vitejs/plugin-react";
import { cloudflare } from "@cloudflare/vite-plugin";
export default defineConfig(({ mode }) => {
// Load env variables
const env = loadEnv(mode, process.cwd(), '');
return {
plugins: [react(), cloudflare()],
server: {
port: 4001,
strictPort: true, // Force the specified port
proxy: {
// Proxy API requests to wrangler dev server
'/api': {
target: 'http://localhost:8787',
changeOrigin: true,
secure: false,
}
}
},
define: {
// Make environment variables available to client and server code
'process.env.API_ENV': JSON.stringify(env.API_ENV || 'development'),
'process.env.AUTH_API_URL': JSON.stringify(env.AUTH_API_URL || 'https://sesh-tracker.com/api/auth'),
'process.env.API_TOKEN': JSON.stringify(env.API_TOKEN),
// Expose the env variables specifically for the worker context
__API_ENV__: JSON.stringify(env.API_ENV || 'development'),
__AUTH_API_URL__: JSON.stringify(env.AUTH_API_URL || 'https://sesh-tracker.com/api/auth'),
__API_TOKEN__: JSON.stringify(env.API_TOKEN),
}
}
});