Bug (and workaround): 404 page returns HTTP 200

@SmashManiac Thanks!

For what it’s worth, I agree with you that the existing handling is bizarre.

I’m not proposing this as the solution, but imagine if the string response for a “page not found” was set via a different means, perhaps the Netlify UI. It would be hard for an argument to be made that requesting /404 should return a 200 status. With no file there, it’d be crazy to return 200 for that route.

It’s the chosen implementation, where the string response for a ‘page not found’ is defined in a convenient /404.html file, that results in it being a file, deployed the same as any other, whereby it seems sane that a direct request would return a 200 status.

But why is it a deployed resource the same as any other?

If you don’t have a custom 404 page then /404 furnishes a 404 status:
https://test.netlify.app/404

If you do have a custom 404 page then /404 furnishes a 200 status:
https://www.netlify.com/404

That’s… weird.

I can understand why Netlify say “200 is correct, the file exists”.
I can’t understand why the file needs to exist.

1 Like