Next.js Discord

Discord Forum

Return not found from a proxy/middleware

Unanswered
Tomistoma posted this in #help-forum
Open in Discord
TomistomaOP
Hi there! I have some proxy/middleware handling that in some case should return my not-found.tsx.

But using notFound() is disallowed in proxy/middleware. and to return NextResponse.error() just returns a plain 500 server error, which is also not what we want.

Is there any way to do this? Without like redirecting to a /404 url.

1 Reply

Pacific sand lance
hm, maybe set header X, then if X is present and it's value is Y throw notFound()