diff options
| author | saltycrys <73420320+saltycrys@users.noreply.github.com> | 2021-01-04 05:24:08 +0100 |
|---|---|---|
| committer | saltycrys <73420320+saltycrys@users.noreply.github.com> | 2021-01-04 05:24:08 +0100 |
| commit | 8b56a038b7c30cb41dbaf67dd42566d84787d79f (patch) | |
| tree | 8991eb22f4191dbc23a6b53f966bdae59a70ccc9 /src | |
| parent | 28dac81a90c9c345f926369da94854c76b212d36 (diff) | |
| download | invidious-8b56a038b7c30cb41dbaf67dd42566d84787d79f.tar.gz invidious-8b56a038b7c30cb41dbaf67dd42566d84787d79f.tar.bz2 invidious-8b56a038b7c30cb41dbaf67dd42566d84787d79f.zip | |
Set content type for HTML error helpers
This fixes `Unexpected char '<' at 1:1` errors caused by content type mismatch.
Diffstat (limited to 'src')
| -rw-r--r-- | src/invidious/helpers/errors.cr | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/invidious/helpers/errors.cr b/src/invidious/helpers/errors.cr index 4487ff8c..2c62d44b 100644 --- a/src/invidious/helpers/errors.cr +++ b/src/invidious/helpers/errors.cr @@ -26,6 +26,7 @@ def error_template_helper(env : HTTP::Server::Context, config : Config, locale : if exception.is_a?(InfoException) return error_template_helper(env, config, locale, status_code, exception.message || "") end + env.response.content_type = "text/html" env.response.status_code = status_code issue_template = %(Title: `#{exception.message} (#{exception.class})`) issue_template += %(\nDate: `#{Time::Format::ISO_8601_DATE_TIME.format(Time.utc)}`) @@ -43,6 +44,7 @@ def error_template_helper(env : HTTP::Server::Context, config : Config, locale : end def error_template_helper(env : HTTP::Server::Context, config : Config, locale : Hash(String, JSON::Any) | Nil, status_code : Int32, message : String) + env.response.content_type = "text/html" env.response.status_code = status_code error_message = translate(locale, message) return templated "error" |
