vite-plugin-proxy

what `devServer.proxy` is for `webpack-dev-server`, `vite-plugin-proxy` is for `vite`
15,960
Install
npm install vite-plugin-proxy
Latest Version:0.5.0
License:MIT
Last Updated:May 11, 2020
Links: npm
Maintainer: zigomir

vite-plugin-proxy

what devServer.proxy is for webpack-dev-server, vite-plugin-proxy is for vite

it's a vite plugin that proxies your requests

usage

also see /example dir

npm install vite-plugin-proxy --save-dev
# or
yarn add -D vite-plugin-proxy
// vite.config.js # or vite.config.ts
const proxyPlugin = require('vite-plugin-proxy')

module.exports = {
  plugins: [
    proxyPlugin({
      '/api': {
        // for option docs see https://github.com/chimurai/http-proxy-middleware#options
        target: 'https://reqres.in',
        changeOrigin: true,
        onProxyRes: (proxyRes) => {
          // cache all responses for faster development
          // use browser's "Disable cache" in dev tools when you need to update API responses
          proxyRes.headers['Cache-Control'] = `public, max-age=${ONE_YEAR_IN_SECONDS}`
          // delete headers you don't want
          delete proxyRes.headers['expires']
        },
      },
    }),
  ],
}

credit

mostly shamelessly stolen from https://github.com/sunyongjian/koa2-proxy-middleware

Related Packages

vite-plugin-vue2

Vite plugin for Vue2

1,474,659 618
@vue-vine/vite-plugin

Official Vite plugin for Vue Vine

95,680 1,442
vite-plugin-git-revision

Vite plugin that generates VERSION and COMMITHASH files during build based on a...

21,961 11
vite-plugin-resolve-extension-vue

A temporary workaround for issue No loader is configured for ".vue"

6,993 5
@koala/yibin-ui

宜宾大脑主题定制

4,077

Version History

Version Released License
0.5.0 MIT
0.4.0 MIT
0.3.0 MIT
0.2.0 MIT
0.1.0 MIT