Repository navigation
Allow notFound(), forbidden(), and unauthorized() to be called from proxy.ts #95359
sss-Mihail-sss
started this conversation in
Ideas
Replies: 2 comments
|
Up! |
0 replies
|
You can do something like this: return NextResponse.rewrite(new URL("/not-found", request.url), {
status: 404,
}); |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Currently,
proxy.tsis the earliest place where an application can inspect an incoming request and decide whether it should continue, redirect, rewrite, or return a custom response.For authentication, authorization, and route-level access control, it would be very useful to call the same App Router interruption APIs from
proxy.ts:The motivation is to keep access-control decisions close to the request boundary while still reusing the standard App Router error UI:
app/not-found.tsxapp/forbidden.tsxapp/unauthorized.tsxToday, the alternative is usually to manually return a
NextResponse, rewrite to a dedicated route, or duplicate authorization checks inside layouts/pages. This works, but it creates different behavior between access checks performed inproxy.tsand access checks performed inside route segments.It would be helpful if
proxy.tscould either:notFound(),forbidden(), andunauthorized()directly; orQuestions:
proxy.tsaligned with the direction of Proxy?notFound,forbidden, andunauthorizedbehavior between Proxy and App Router segments?All reactions