Skip to content

Commit

Permalink
fix(packages): [vite-plugin-http2-proxy] stop work in node v20+
Browse files Browse the repository at this point in the history
  • Loading branch information
buqiyuan committed Apr 9, 2024
1 parent f6a8090 commit 354fc0d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/sync-to-gitee.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: syncToGitee
name: Sync To Gitee
env:
# 7 GiB by default on GitHub, setting to 6 GiB
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
Expand Down
8 changes: 8 additions & 0 deletions packages/vite-plugin-http2-proxy/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { version } from 'node:process';
import http2Proxy from 'http2-proxy';
import type { Plugin, ProxyOptions } from 'vite';

Expand All @@ -8,6 +9,13 @@ const error = (message: string): never => {
export default (options?: Record<string, ProxyOptions>): Plugin => {
let routes: Record<string, ProxyOptions>;

if (version.startsWith('v2')) {
console.warn(
'[@admin-pkg/vite-plugin-http2-proxy] http2-proxy is not supported in Node.js v20.x+',
);
return { name: '@admin-pkg/vite-plugin-http2-proxy' };
}

const configure: Plugin['configureServer'] = ({ middlewares, httpServer }) => {
const proxyOptions = options || routes;
for (const [regexp, serverOptions] of Object.entries(proxyOptions)) {
Expand Down

0 comments on commit 354fc0d

Please sign in to comment.