UNPKG

next

Version:

The React Framework

33 lines (32 loc) 1.54 kB
import { HTTP_ERROR_FALLBACK_ERROR_CODE } from './http-access-fallback/http-access-fallback'; // TODO: Add `forbidden` docs /** * @experimental * This function allows you to render the [forbidden.js file](https://nextjs.org/docs/app/api-reference/file-conventions/forbidden) * within a route segment as well as inject a tag. * * `forbidden()` can be used in * [Server Components](https://nextjs.org/docs/app/building-your-application/rendering/server-components), * [Route Handlers](https://nextjs.org/docs/app/building-your-application/routing/route-handlers), and * [Server Actions](https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations). * * Read more: [Next.js Docs: `forbidden`](https://nextjs.org/docs/app/api-reference/functions/forbidden) */ const DIGEST = "" + HTTP_ERROR_FALLBACK_ERROR_CODE + ";403"; export function forbidden() { if (!process.env.__NEXT_EXPERIMENTAL_AUTH_INTERRUPTS) { throw Object.defineProperty(new Error("`forbidden()` is experimental and only allowed to be enabled when `experimental.authInterrupts` is enabled."), "__NEXT_ERROR_CODE", { value: "E488", enumerable: false, configurable: true }); } // eslint-disable-next-line no-throw-literal const error = Object.defineProperty(new Error(DIGEST), "__NEXT_ERROR_CODE", { value: "E394", enumerable: false, configurable: true }); error.digest = DIGEST; throw error; } //# sourceMappingURL=forbidden.js.map