Return error code 404 (Not found) for blocked resources in production mode.

In dev mode return 500 so the user can see the error displayed on the screen and fix it

(cherry picked from commit dbad8851b184f4df81b61544fdabac6659029e0f)