mirror of
https://github.com/jsbin/jsbin.git
synced 2026-01-18 15:18:04 +00:00
Don't send headers if they're not asked for
This commit is contained in:
parent
ba362b6b74
commit
ee4792c782
@ -51,7 +51,7 @@ var middleware = module.exports = {
|
||||
var origin = req.header('Origin');
|
||||
|
||||
// TODO should this check if the request is via the API?
|
||||
if (req.method === 'OPTIONS' || (req.method === 'GET' && utils.isAjax(req)) || (req.method === 'GET' && req.headers.origin)) {
|
||||
if (req.method === 'OPTIONS' || (req.method === 'GET' && req.headers.origin)) {
|
||||
res.header({
|
||||
'Access-Control-Allow-Origin': origin,
|
||||
'Access-Control-Allow-Headers': headers,
|
||||
|
||||
@ -133,7 +133,7 @@ module.exports = {
|
||||
return collected;
|
||||
},
|
||||
isAjax: function (req) {
|
||||
return (req.get('X-Requested-With') || '').toLowerCase() === 'xmlhttprequest';
|
||||
return (req.get('X-Requested-With') || '').toLowerCase() === 'xmlhttprequest' || req.accepted[0].value === 'application/json';
|
||||
},
|
||||
shortcode: function (length) {
|
||||
var vowels = 'aeiou',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user