1.0.0 • Published 3 years ago

vite-plugin-proxy-with-http2 v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

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