vbenjs / vue-vben-admin

A modern vue admin panel built with Vue3, Shadcn UI, Vite, TypeScript, and Monorepo. It's fast!
https://www.vben.pro
MIT License
25.32k stars 6.89k forks source link

Bug: 部署nginx 启用brotli 当启用brotli_static no; 会报错 net::ERR_CONTENT_DECODING_FAILED 200 (OK) #4493

Open wangz-code opened 1 month ago

wangz-code commented 1 month ago

Version

Vben Admin V5

Describe the bug?

vue-vben-admin-5.3.0 https://github.com/vbenjs/vue-vben-admin/releases/tag/v5.3.0

.env.production

# 是否开启压缩,可以设置为 none, brotli, gzip
VITE_COMPRESS=brotli

npm run build:naive

nginx 配置

    brotli on;  
    brotli_types text/plain text/css text/xml application/xml application/json text/javascript application/javascript application/x-javascript;
    brotli_static on; #只要这里设置为 on 就会报错,  off 就正常
    brotli_comp_level 6;

访问就会提示 net::ERR_CONTENT_DECODING_FAILED 200 (OK)

image

Reproduction

null

System Info

No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye

nginx version: nginx/1.26.2
built with OpenSSL 1.1.1w  11 Sep 2023
TLS SNI support enabled

Relevant log output

No response

Validations

wangz-code commented 1 month ago

我测试在 vite.config.mts 配置中 使用rollup-plugin-gzip 打包后测试正常

build: {
        rollupOptions: {
          plugins: [
            gzipPlugin({
              customCompression: (content) => brotliPromise(Buffer.from(content)),
              fileName: '.br',
            }),
          ],
        },

      },