-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(config): add Swagger proxy settings in Vite configuration
- Loading branch information
Showing
1 changed file
with
20 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
import { defineConfig } from "vite"; | ||
import { type ProxyOptions, defineConfig } from "vite"; | ||
import react from "@vitejs/plugin-react-swc"; | ||
|
||
const SERVER_URL = "http://localhost:8080"; | ||
|
||
const proxyOptions: ProxyOptions = { | ||
target: SERVER_URL, | ||
changeOrigin: true, // Recommended for avoiding CORS issues | ||
ws: true, // WebSocket support for hot module replacement | ||
}; | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
plugins: [react({ devTarget: "es2022" })], | ||
server: { | ||
port: 3000, | ||
strictPort: true, | ||
proxy: { | ||
"/v1": SERVER_URL, | ||
"/version": SERVER_URL, | ||
"/ws": SERVER_URL, | ||
export default defineConfig(({ mode }) => { | ||
const isDesktopMode = mode === "desktop"; | ||
|
||
return { | ||
base: isDesktopMode ? "/static/" : "/", // Sets base to "/static/" in Desktop mode for compatible static file serving, otherwise root. | ||
plugins: [react({ devTarget: "es2022" })], | ||
server: { | ||
port: 3000, | ||
strictPort: true, | ||
proxy: { | ||
"^/(v1|health|kill|version|ws|openapi.json)": proxyOptions, | ||
}, | ||
}, | ||
}, | ||
}; | ||
}); |