字数:379 字
预计:2 分钟
阅读量:11
Rsbuild 使用 HTTP2
作者:winches
更新于:7 个月前
官网开启 https 后,默认使用 http2 协议,https://rsbuild.dev/config/server/https
但是目前还不支持 http2 的 proxy,所以还需要手动实现 http2-proxy 的代理
升级步骤
- 安装
@rsbuild/plugin-basic-ssl
插件,自动配置 https 证书和开启 https - 安装
http2-proxy
库,实现 http2 的代理 - 修改
rsbuild.config.ts
配置,添加 http2-proxy 的代理中间件
ts
ts
// rsbuild.config.ts
const config = {
dev: {
setupMiddlewares: [
(middleware) => {
// @ts-expect-error type mismatch
middleware.unshift(...proxyMiddlewares)
},
]
}
}