summaryrefslogtreecommitdiff
path: root/react/07-react-router/vite.config.js
diff options
context:
space:
mode:
Diffstat (limited to 'react/07-react-router/vite.config.js')
-rw-r--r--react/07-react-router/vite.config.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/react/07-react-router/vite.config.js b/react/07-react-router/vite.config.js
new file mode 100644
index 0000000..f0b256a
--- /dev/null
+++ b/react/07-react-router/vite.config.js
@@ -0,0 +1,23 @@
+import { defineConfig } from 'vite'
+import react from '@vitejs/plugin-react'
+
+// https://vite.dev/config/
+export default defineConfig({
+ plugins: [react()],
+
+ // Forward requests to /bff/api to another server (like json-server)
+ server: {
+ proxy: {
+ '/bff/api': {
+ target: 'http://localhost:3000',
+
+ changeOrigin: true, // Rewrites the host header to match the target
+
+ secure: false, // Allows self-signed SSL certificates for HTTPS targets
+
+ // Strips out '/bff/api' before passing the request to the target server
+ rewrite: (path) => path.replace(/^\/bff\/api/, ''),
+ }
+ }
+ }
+})