#How to use 404 page as response in Middleware while preserving the URL?

4 messages · Page 1 of 1 (latest)

normal agate
#

I have an authentication check in my middleware and if the user fails it, I want to show them the 404.astro page. Responding with the below doesn't use the 404.astro page (though that page is used for arbitrary unknown routes).

How can I preserve the current URL but show the 404 page?

return new Response(null, { status: 404, statusText: 'Not found' })
hollow stag
#

I dont think preserving the current the URL but showing the 404 page is possible. You would just redirect them to the 404 page.

normal agate
#

Ah, that's a bummer. Hopefully that will be possible eventually. Thanks for the quick response!

tepid cairn