vite-server-plugin-proxy
TypeScript icon, indicating that this package has built-in type declarations

1.0.0-rc.1 • Public • Published

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

Dependencies (0)

    Dev Dependencies (10)

    Package Sidebar

    Install

    npm i vite-server-plugin-proxy

    Weekly Downloads

    80

    Version

    1.0.0-rc.1

    License

    MIT

    Unpacked Size

    7.58 kB

    Total Files

    7

    Last publish

    Collaborators

    • luxueyan