-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
44 lines (40 loc) · 1.18 KB
/
vite.config.js
File metadata and controls
44 lines (40 loc) · 1.18 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
35
36
37
38
39
40
41
42
43
44
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vite.dev/config/
export default defineConfig({
plugins: [vue()],
// Base path for GitHub Pages
base: process.env.NODE_ENV === 'production' ? '/Registry-Lens/' : '/',
build: {
// Output directory
outDir: 'dist',
// Generate sourcemaps for debugging
sourcemap: false
},
server: {
port: 5173,
// CORS proxy for local development only
// In production (GitHub Pages), registry must have CORS enabled
proxy: {
'/registry-api': {
target: 'http://localhost:5000',
changeOrigin: true,
secure: false,
rewrite: (path) => path.replace(/^\/registry-api/, '/v2'),
configure: (proxy, options) => {
proxy.on('proxyReq', (proxyReq, req) => {
const registryUrl = req.headers['x-registry-url']
if (registryUrl) {
try {
const url = new URL(registryUrl)
options.target = `${url.protocol}//${url.host}`
} catch (e) {
console.error('Invalid registry URL:', registryUrl)
}
}
})
}
}
}
}
})