Skip to content

Commit

Permalink
moving the location of the CORS headers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpowell committed Mar 25, 2012
1 parent 757841e commit 71e601b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions web.js
Expand Up @@ -4,6 +4,12 @@ var //pinboard = require('pinboard'),
express = require('express'),
server = express.createServer();

server.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});

server.get('*', function (req, res) {
var header = req.headers['authorization'] || '', // get the header
token = header.split(/\s+/).pop() || '', // and the encoded auth token
Expand All @@ -23,8 +29,6 @@ server.get('*', function (req, res) {
url: url + req.path
}, function (error, response, body) {
parser.toJson(body, function (x, obj) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.json(obj);
});
});
Expand Down

0 comments on commit 71e601b

Please sign in to comment.