Skip to content

Commit a1571c7

Browse files
committedJan 27, 2017
Explicitly set json type for error responses
1 parent 2b76923 commit a1571c7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed
 

‎bearer.lua

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ end
1919
-- finally, if still no JWT token, kick out an error and exit
2020
if token == nil then
2121
ngx.status = ngx.HTTP_UNAUTHORIZED
22+
ngx.header.content_type = "application/json; charset=utf-8"
2223
ngx.say("{error: \"missing JWT token or Authorization header\"}")
2324
ngx.exit(ngx.HTTP_UNAUTHORIZED)
2425
end
@@ -40,6 +41,7 @@ local jwt_obj = jwt:verify(os.getenv("JWT_SECRET"), token, claim_spec)
4041
if not jwt_obj["verified"] then
4142
ngx.status = ngx.HTTP_UNAUTHORIZED
4243
ngx.log(ngx.WARN, jwt_obj.reason)
44+
ngx.header.content_type = "application/json; charset=utf-8"
4345
ngx.say("{error: \"" .. jwt_obj.reason .. "\"}")
4446
ngx.exit(ngx.HTTP_UNAUTHORIZED)
4547
end

0 commit comments

Comments
 (0)