vite-server-plugin-proxy
v1.0.0-rc.1
Published
A server proxy plugin support router config like http-proxy-middleware
Downloads
8
Readme
vite-server-plugin-proxy ⚡
This plugin support router config like http-proxy-middleware
Status
In rc.1 and will likely release 1.0 soon.
Getting Started
Install (yarn or npm)
yarn add vite-server-plugin-proxy
or npm i vite-server-plugin-proxy
Usage
Example:
// vite.config.js
const defaultProxy = 'http://localhost:3000'
module.exports = {
proxies: {
'/api': {
target: defaultProxy,
proxyTimeout: 1500000,
timeout: 1500000,
changeOrigin: true,
router: function (req) {
if (req.query._proxy) {
const proxyTarget = req.query._proxy
return proxyTarget
}
console.log(req.path, `: proxy to ${defaultProxy}`)
return defaultProxy
},
}
}
}
License
MIT