From c13d2648be963d9248a6ce96bd8b5e6c48570cca Mon Sep 17 00:00:00 2001 From: John B Date: Sun, 17 Dec 2023 16:03:08 +0100 Subject: [PATCH] add proxy example --- vite.config.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vite.config.ts b/vite.config.ts index 67ff450..ad38b5c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,12 +1,23 @@ import { defineConfig } from "vitest/config"; import react from "@vitejs/plugin-react"; +// add proxy, optional +const proxy: { [l: string]: ProxyOptions } = { + "^/api/.*": { + target: "http://localhost:3002", + changeOrigin: true, + secure: false, + rewrite: (path: string) => path.replace(/^\/api\/, ""), + }, +}; + // this the default/base configuration const baseConfig = { plugins: [react()], test: { // ... - } + }, + server: { proxy } }; // https://vitejs.dev/config/