Skip to content

Instantly share code, notes, and snippets.

@tmatz
Created September 28, 2022 06:32
Show Gist options
  • Save tmatz/5dd49c4449167b0c96085b165fc7be88 to your computer and use it in GitHub Desktop.
Save tmatz/5dd49c4449167b0c96085b165fc7be88 to your computer and use it in GitHub Desktop.
server.proxy via http_proxy with vite.js
import react from '@vitejs/plugin-react'
import ProxyAgent from 'proxy-agent'
import { defineConfig } from 'vite'
// https://vitejs.dev/config/
export default defineConfig({
server: {
open: true,
proxy: {
'/api/': {
target: 'https://example.com',
secure: false,
agent: new ProxyAgent(),
},
},
},
plugins: [react()],
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment