Files
mediahive/frontend/vite-plugin-fastapi.js
T
2026-02-07 00:21:32 +00:00

37 lines
900 B
JavaScript

/**
* FastAPI-Vue Vite Plugin
* auto-upgrade@fastapi-vue-setup -- remove this if you edit the plugin
*
* Configures Vite for FastAPI backend integration:
* - Proxies /api/* requests to the FastAPI backend
* - Builds to the Python module's frontend-build directory
*
* Options:
* paths - Array of paths to proxy (default: ["/api"])
*/
export default function fastapiVue({ paths = ["/api"] } = {}) {
const backendUrl = process.env.MEDIAHIVE_BACKEND_URL || "http://localhost:8420"
// Build proxy configuration for each path
const proxy = {}
for (const path of paths) {
proxy[path] = {
target: backendUrl,
changeOrigin: false,
ws: true,
}
}
return {
name: "vite-plugin-fastapi-mediahive",
config: () => ({
server: { proxy },
build: {
outDir: "../mediahive/frontend-build",
emptyOutDir: true,
},
}),
}
}