@cpsoinos/vite-plugin-http2-proxy

中文文档
0.1.0发布于 2024/02/25MITTypeScriptESM + CJS近 30 天下载 2.3万

一个 Vite 插件,允许您向 HTTP2 服务器代理请求 .

中文使用文档
文档目录9 节
  1. 我为什么要用这个?
  2. 安装
  3. 使用 npm
  4. 使用 yarn
  5. 使用 pnpm
  6. 使用量
  7. 核证
  8. 显示您的支持
  9. 许可证

维特-插管- http2- 代用

与 Vite 在开发模式中运行 HTTP2 代理 。 配对时效果不错 阴道插孔- mkcert。 。 。 .

我为什么要用这个?

当使用 Vite 内置代理和 https: true,所有请求被降级到HTTP1.1. 见 这个问题 讨论。 此插件在开发模式中需要代理请求到外部 API 时有用, 您想要使用 https 和/或 HTTP2.

用这个 阴道插孔- mkcert 用于无缝的 SSL 证书生成和使用 https , 并在开发中使用代理用户.

安装

使用 npm

npm install @cpsoinos/vite-plugin-http2-proxy --save-dev

使用 yarn

yarn add @cpsoinos/vite-plugin-http2-proxy -D

使用 pnpm

pnpm add @cpsoinos/vite-plugin-http2-proxy -D

使用量

// vite.config.ts

import { defineConfig } from 'vite'
import http2Proxy from '@cpsoinos/vite-plugin-http2-proxy'
import mkcert from 'vite-plugin-mkcert' // optional - use to generate SSL certificates and use https in development

export default defineConfig(({ mode }) => {
  return {
    plugins: [
      // ... other plugins
      mkcert(), // optional
      http2Proxy({ quiet: true }), // optional -- suppress error logging
    ],
    server: {
      // optional - only in development mode
      ...(mode === 'development' && {
        proxy: {
          '/api': {
            target: 'https://api.example.com',
            changeOrigin: true,
            rewrite: (path) => path.replace(/^\/api/, ''), // optional - remove `/api` from request path
          },
        },
      }),
    },
  }
})

核证

改编自 属性 由 @ xfournet 共享 这个问题的评论。 。 。 .

此插件使用 http2-proxy 在引擎盖下。 见 http2-正则 用于获取更多信息的软件包.

显示您的支持

如果这个计划能帮助你的话,就给你一个!

许可证

版权 2024 科里·普苏伊诺斯。 。 。 .

这个项目是 麻省理工学院 有执照.

版本与发布记录

@cpsoinos/vite-plugin-http2-proxy 共发布 2 个版本,首次发布于 2024/02/25;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.0latest2024/02/252 年前
0.0.12024/02/252 年前

关于 @cpsoinos/vite-plugin-http2-proxy 的常见问题

@cpsoinos/vite-plugin-http2-proxy 是什么?

一个 Vite 插件,允许您向 HTTP2 服务器代理请求 .

如何安装 @cpsoinos/vite-plugin-http2-proxy?

在项目目录运行 npm install @cpsoinos/vite-plugin-http2-proxy,或使用 pnpm add / yarn add / bun add。

@cpsoinos/vite-plugin-http2-proxy 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@cpsoinos/vite-plugin-http2-proxy 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@cpsoinos/vite-plugin-http2-proxy 可以商用吗?

@cpsoinos/vite-plugin-http2-proxy 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@cpsoinos/vite-plugin-http2-proxy 的下载量有多少?

根据 npm 官方下载统计,@cpsoinos/vite-plugin-http2-proxy 在 2026/10/11 – 2026/11/09 这 30 天内被下载 22,693 次,日均约 756 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@cpsoinos/vite-plugin-http2-proxy 还在维护吗?

最新版本 0.1.0 发布于 2024/02/25(2 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/02/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。