feat: redirect 404/500 to static pages (#14677)

* feat: redirect 404/500 to static pages

* Show pages only on html requests
This commit is contained in:
Beto Dealmeida 2021-05-18 20:50:39 -07:00 committed by GitHub
parent 065b3f933d
commit c3d1f1084e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -94,7 +94,7 @@
<section>
<h1>Page not found</h1>
<p>
Sorry, we cannot find t he page you are looking for. You may have
Sorry, we cannot find the page you are looking for. You may have
mistyped the address or the page may have moved.
</p>
<a href="/" class="button">Back to home</a>

View File

@ -385,6 +385,13 @@ def refresh_csrf_token(ex: CSRFError) -> FlaskResponse:
@superset_app.errorhandler(HTTPException)
def show_http_exception(ex: HTTPException) -> FlaskResponse:
logger.warning(ex)
if (
"text/html" in request.accept_mimetypes
and not config["DEBUG"]
and ex.code in {404, 500}
):
return redirect(f"/static/assets/{ex.code}.html")
return json_errors_response(
errors=[
SupersetError(