34 lines
1.3 KiB
TypeScript
Vendored
34 lines
1.3 KiB
TypeScript
Vendored
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
|
|
/**
|
|
* image-gen is served from inside new-api at `/image-gen/`. In production the
|
|
* built `dist/` is embedded in the Go binary and served by the same origin
|
|
* as new-api (so /api/* and /v1/* work via session cookies, no CORS).
|
|
*
|
|
* In dev, you typically run `npm run dev` here and the Vite server proxies
|
|
* `/api`, `/mj`, `/pg` to new-api. We default to http://localhost:3000
|
|
* (new-api dev backend), but you can override with VITE_NEWAPI_BASE.
|
|
*/
|
|
const newapiBase = process.env.VITE_NEWAPI_BASE ?? 'http://localhost:3000'
|
|
|
|
export default defineConfig({
|
|
plugins: [vue()],
|
|
// The built assets reference absolute paths under /image-gen/ so the
|
|
// Go server (which embeds the dist and serves from any /image-gen* URL,
|
|
// including the no-slash form that gin-contrib/static may redirect to)
|
|
// can always find them at /image-gen/assets/*.
|
|
base: '/image-gen/',
|
|
server: {
|
|
port: 5174,
|
|
host: '0.0.0.0',
|
|
proxy: {
|
|
'/api': { target: newapiBase, changeOrigin: true },
|
|
'/v1': { target: newapiBase, changeOrigin: true },
|
|
'/mj': { target: newapiBase, changeOrigin: true },
|
|
'/pg': { target: newapiBase, changeOrigin: true },
|
|
'/assets': { target: newapiBase, changeOrigin: true },
|
|
},
|
|
},
|
|
})
|