summaryrefslogtreecommitdiff
path: root/react/07-react-router/vite.config.js
blob: f0b256a0610e720aa7aae48e96fc258e06dbb83b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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/, ''),
      }
    }
  }
})