-
Notifications
You must be signed in to change notification settings - Fork 6
/
vite.config.ts
47 lines (44 loc) · 1.28 KB
/
vite.config.ts
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
35
36
37
38
39
40
41
42
43
44
45
46
47
import path from "path"
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import dotenv from 'dotenv'
// Load environment variables from .env file
dotenv.config();
const BEARER_TOKEN = process.env.ASTRIA_API_KEY;
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
// Set base URL to "/imagine/" by default, or "" if explicitly set to "false"
base: process.env.VITE_DEPLOY_TO_ASTRIA === "true" ? "/imagine/" : "",
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
server: {
port: 5173,
...(BEARER_TOKEN && {
proxy: {
'/api': {
target: 'https://api.astria.ai',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''),
configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => {
proxyReq.setHeader('Authorization', `Bearer ${BEARER_TOKEN}`);
});
}
},
'/rails/active_storage/blobs': {
target: 'https://api.astria.ai',
changeOrigin: true,
configure: (proxy) => {
proxy.on('proxyReq', (proxyReq) => {
proxyReq.setHeader('Authorization', `Bearer ${BEARER_TOKEN}`);
});
}
}
}
})
}
})