Vercel 支持自定义平台错误页:企业用户可统一 5xx 品牌体验

1 分钟阅读
2026 年 1 月 23 日
现在,你可以在 Vercel 上为平台错误自定义错误页面,用你自己的品牌化体验替换通用错误页。当 Vercel 遇到未捕获错误(例如函数调用超时)或其他平台错误时,就会显示自定义错误页。
Link to heading工作原理
你可以按照所用框架的约定来实现自定义错误页,Vercel 会自动定位这些页面。比如在 Next.js 中,你只需放置 500/page.tsx,或者在 public 目录下放置静态 500.html 页面。
为了在错误页中补充与请求相关的上下文信息,你可以使用以下元数据 Token:
-
::vercel:REQUEST_ID::- 包含 Vercel 请求 ID -
::vercel:ERROR_CODE::- 具体错误码,例如FUNCTION_INVOCATION_TIMEOUT
500/page.tsx
export default function CustomErrorPage() { return ( <div className="flex min-h-screen flex-col items-center justify-center"> <h1 className="text-4xl font-bold">500</h1> <p className="mt-4 text-lg text-gray-600">Internal Server Error</p> <p className="mt-2 text-sm text-gray-500"> Request ID: ::vercel:REQUEST_ID:: </p> <p className="mt-2 text-sm text-gray-500"> Code: ::vercel:ERROR_CODE:: </p> <p className="mt-2 text-sm text-gray-500"> Something went wrong on our end. Please try again later. </p> <a href="/" className="mt-6 text-blue-600 hover:underline"> Go back home </a> </div> );}
我们强烈建议在页面中包含请求 ID 和错误码,以便于调试与支持排查。
该功能面向 Enterprise 团队开放,并已在所有项目中自动启用,无需任何额外配置。
可查看文档快速上手,或参考以下实现示例:使用 App Router 的自定义错误页 或 使用 public 目录的自定义错误页。
原文链接:https://vercel.com/changelog/vercel-now-supports-customizing-platform-error-pages

