# VitePress Cloudflare 预取错误解决方案

URL: https://caijiao.org/posts/40
Source: docs/posts/40.md
Description: 当 VitePress 部署到 Cloudflare Pages 后，浏览器控制台出现 “net::ERR_ABORTED 503 (Service Unavailable)” 报错，通常与 Cloudflare 的 Speed Brain（智能内容优化）预取功能有关。本文介绍关闭该功能的解决方法。

在 Cloudflare Pages 部署 VitePress 网站后，有用户在浏览器控制台看到如下报错：

![VitePress 在 Cloudflare 出现 prefetch 报错 net::ERR_ABORTED 50](/images/posts/20251030102332.jpg)

```txt
net::ERR_ABORTED 503 (Service Unavailable)
````

该问题常出现在静态资源（如 `.js` 文件）被 Cloudflare 的 **Speed Brain 内容优化** 功能预取时。

## 问题原因

Cloudflare 的 “Speed Brain” 会自动尝试对页面进行智能内容优化与预加载（prefetch），在静态站点中可能导致资源请求中断或缓存异常，尤其是在 VitePress 的动态模块加载机制（如 `prefetch` JS chunk）下。

## 解决方法

1. 登录 **Cloudflare 控制台**
2. 进入你的站点 → **速度 - 设置 - 内容优化**
3. 找到 **Speed Brain**
4. 将其 **关闭**

关闭后刷新页面，`503 (Service Unavailable)` 报错将会消失。

## 补充说明

如果你希望进一步优化 VitePress 加载行为，也可以在 `vitepress.config.js` 中禁用 `prefetch`：

```js
export default {
  vite: {
    build: {
      rollupOptions: {
        output: {
          manualChunks: undefined
        }
      }
    }
  }
}
````


关闭 Speed Brain 不会影响 Cloudflare Pages 的基础加速与缓存性能，仅禁用预取优化。
