forbidden.js
此功能目前為實驗性質,可能會有所變動,不建議用於生產環境。請試用並在 GitHub 上分享您的意見回饋。
當驗證期間調用 forbidden
函式時,forbidden 檔案會用於渲染 UI。除了讓您自訂 UI 外,Next.js 也會傳回 403
狀態碼。
app/forbidden.tsx
import Link from 'next/link'
export default function Forbidden() {
return (
<div>
<h2>Forbidden</h2>
<p>You are not authorized to access this resource.</p>
<Link href="/">Return Home</Link>
</div>
)
}
參考
Props
forbidden.js
元件不接受任何 props。
版本歷史
版本 | 變更 |
---|---|
v15.1.0 | 引入了 forbidden.js 。 |
這有幫助嗎?