Skip to content

Commit

Permalink
fix(config): add Swagger proxy settings in Vite configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
hdinia committed Feb 1, 2024
1 parent 00b3876 commit 90040f6
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions webapp/vite.config.ts
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,
},
},
},
};
});

0 comments on commit 90040f6

Please sign in to comment.