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

1.0.0 • Public • Published

vite-plugin-proxy-with-http2

a vite plugin that enables http2 and proxy at the same time

Usage

1. Install

npm i vite-plugin-proxy-with-http2 -D

2. Add it to vite.config.js

// vite.config.js
import {defineConfig} from 'vite'
import fs from 'fs'
import VitePluginProxyWithHttp2 from "vite-plugin-proxy-with-http2";

export default defineConfig({
    server: {
        https: {
            // SSL certificate config
            key: fs.readFileSync('./.cert/localhost-key.pem'),
            cert: fs.readFileSync('./.cert/localhost.pem'),
        },
    },
    plugins: [
        VitePluginProxyWithHttp2({
            // config 
            proxy: [
                {
                    context: '/api/**',
                    target: 'http://your-host:port', // port is optinal
                    pathRewrite: {'^/api': '/api-new'}
                }
            ]
        })
    ]
})

License

MIT License © 2022 dirkwei

Readme

Keywords

none

Package Sidebar

Install

npm i vite-plugin-proxy-with-http2

Weekly Downloads

5

Version

1.0.0

License

MIT

Unpacked Size

4.58 kB

Total Files

8

Last publish

Collaborators

  • inspiration520