1.0.0-rc.1 • Published 4 years ago

vite-server-plugin-proxy v1.0.0-rc.1

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

vite-server-plugin-proxy ⚡

npm node

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