Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details →
Socket
Book a DemoInstallSign in
Socket

vite-plugin-h2-proxy

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vite-plugin-h2-proxy

đź’Ą A vite plugin that resolve the conflict between http2 and proxy

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
89
-46.39%
Maintainers
1
Weekly downloads
 
Created
Source

vite-plugin-h2-proxy

đź’Ą A vite plugin that resolve the conflict between http2 and proxy

Installation

yarn add vite-plugin-h2-proxy -D
# or
npm i vite-plugin-h2-proxy -D
# or
pnpm i vite-plugin-h2-proxy -D

Usage

In your vite.config.ts:

import { defineConfig } from 'vite'
import vitePluginH2Proxy from 'vite-plugin-h2-proxy'

const _proxy = {
  target: 'http://localhost:8080',
  proxyTimeout: 5000,
  timeout: 5000,
  rewrite: (path) => path.replace(/^\/fallback/, ''),
  onReq(req, proxyReq) {
    proxyReq.headers.origin = 'http://localhost:8080'
  }
  onRes(req, res, proxyRes){
    res.setHeader('set-cookie', proxyRes.headers['set-cookie'] + '; SameSite=None; Secure')
  }
  onError(error){
    console.log(error)
  }
  bypass() {
    return false
  }
}

export default defineConfig({
  plugins: [vitePluginH2Proxy(_proxy)],
})

Type

interface ProxyOptions {
  ws?: boolean
  target: string
  proxyTimeout?: number
  proxyName?: string
  timeout?: number
  bypass?: (...args: any) => boolean
  rewrite?: (path: string) => string
  onReq?: (...args: any) => any
  onRes?: (...args: any) => any
  onError?: (e: Error) => void
}

Features

  • If you want to get proxy log, you can pass the second parameter, like:
vitePluginH2Proxy(_proxy, true)
  • The configuration of proxy item are highly compatible with vite's built-in options of proxy, except configure option.

    Extends http2-proxy. Additional options: onError

Keywords

vite

FAQs

Package last updated on 26 Aug 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts