analytics-reporter
analytics-reporter copied to clipboard
JSON encoding not specified
Regarding a potential fix for GSA/analytics.usa.gov/issues/149, it looks like app/routes.js isn't specifying the character set for the returned JSON. Pulled from StackOverflow #16268244:
Set the
res.header("Content-Type", "application/json; charset=utf-8");so that the browser knows what character set to use.
+1 this solution. The file command thinks the output is UTF-8 encoded, and vim (being utf-8 aware) displays the characters correctly
The dashboard gets JSON from S3 - the Express endpoints here are not currently used in production. This is a good note and we'll integrate the fix, but it won't resolve https://github.com/GSA/analytics.usa.gov/issues/149.
Won't S3 let you set the Content-Type header to include the encoding?
@shawnbot It looks like the content encoding is getting set to gzip?
https://github.com/18F/analytics-reporter/blob/master/bin/analytics#L42-L49
We should update the Content-Type, not the Content-Encoding. Thanks for pointing this out -- we'll fix.
Yeah sorry, I meant that the Content-Type header should be set to application/json; charset=utf-8 on S3, rather than just application/json.
Was this what you had in mind? https://github.com/18F/analytics-reporter/pull/128
@jmhooper, @laurenancona, anyone else here - game to check if https://github.com/18F/analytics-reporter/pull/128 resolved this issue?
@gbinal: I believe it would have, but that is dead code now.