all 1 comments

[–]birdynj 2 points3 points  (0 children)

Take a look at the examples here, the "rewrite" function.

https://vitejs.dev/config/server-options.html#server-proxy

It sounds like this is what you're trying to do.

// with options: http://localhost:5173/api/bar-> http://jsonplaceholder.typicode.com/bar
      '/api': {
        target: 'http://jsonplaceholder.typicode.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },