I am trying to return jsonp from my express, nodejs application and I keep getting text/javascript instead of application/javascript (which I think should be the correct Content-Type). I am not bothered about IE < 8. The various ways that I have tried to set the content-type when returning the result is shown below:
// Method 1
res.setHeader('Content-Type', 'application/javascript');
res.status(200).jsonp(result);
// Method 2
res.format({
'application/javascript': function() {
res.status(200).jsonp(result);
}
});
// Method 3
res.set('Content-Type', 'application/javascript');
res.status(200).jsonp(result);
But no matter what, the Content-Type that I get is always text/javascript as shown below. I also get 'nosniff' header twice in the response headers :-/ I have it only once in my nginx.conf file which I have thoroughly checked. Even did a nginx -t and it says config is fine.
HTTP/1.1 200 OK
Server: nginx
Date: Thu, 12 May 2016 05:06:28 GMT
Content-Type: text/javascript; charset=utf-8
Content-Length: 433
Connection: keep-alive
Keep-Alive: timeout=5
X-Powered-By: Express
Vary: Accept
X-Content-Type-Options: nosniff
ETag: W/"1b1-1ZnUnapTaayP/+6QW4iqXQ"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Strict-Transport-Security: max-age=315360000; includeSubdomains
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Robots-Tag: none
I am using nginx as a reverse proxy using the 'upstream thingy'. I am also using bodyParser in my application. Please let me know if any further information is needed as I am absolutely new to node/express. Thanks