forbidden.js
在身份验证期间调用 forbidden
函数时,禁止文件用于渲染 UI。除了允许你自定义 UI 之外,Next.js 还将返回 403
状态代码。
¥The forbidden file is used to render UI when the forbidden
function is invoked during authentication. Along with allowing you to customize the UI, Next.js will return a 403
status code.
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>
)
}
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>
)
}
参考
¥Reference
属性
¥Props
forbidden.js
组件不接受任何 props。
¥forbidden.js
components do not accept any props.
版本历史
¥Version History
版本 | 变化 |
---|---|
v15.1.0 | forbidden.js 推出。 |