From 15af8e17810ae07e3f58a821a16a364c0f2ee39f Mon Sep 17 00:00:00 2001 From: iye <1713042409@qq.com> Date: Wed, 13 May 2026 14:43:52 +0800 Subject: [PATCH] fix(image): disable next/image optimization for TOS-hosted assets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 桶里资源已是 webp + 预压缩 + CDN, 不需要 Next 16 再做一次 image 优化: - images.unoptimized=true: 直接走 , 浏览器走自己网络栈 - 顺带绕过 dev 时 fake-IP 代理 (Clash/V2Ray TUN 返回 198.18.0.x) 触发的 "resolved to private ip" 拦截 - remotePatterns 保留 (Next 16 即便不优化仍校验域名白名单) 生产 CPU 占用也省了, 不需要在 origin 再编码 webp。 Co-Authored-By: Claude Sonnet 4.6 --- next.config.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/next.config.ts b/next.config.ts index 42227ca..051cb6d 100644 --- a/next.config.ts +++ b/next.config.ts @@ -5,8 +5,13 @@ const nextConfig: NextConfig = { devIndicators: false, // 容器化部署:产出精简的 standalone 包(node server.js 启动) output: "standalone", - // next/image 远程域名白名单:火山 TOS 桶 + 后续 CDN 域名 + // next/image 配置 + // - unoptimized: 关闭服务端 image 优化代理。资源已在 TOS 桶里是 WebP + 适配尺寸, + // 走 CDN,无需 Next.js 再编码一次。还能绕过 dev 时 fake-IP 代理(Clash/V2Ray TUN + // 返回 198.18.x.x)被 Next 16 拒绝 fetch 的问题。 + // - remotePatterns: 即便不优化,Next 16 仍会校验远程域名白名单,保留 TOS + CDN 域名。 images: { + unoptimized: true, remotePatterns: [ { protocol: "https", hostname: "*.tos-cn-shanghai.volces.com" }, { protocol: "https", hostname: "*.tos-cn-beijing.volces.com" },