Permalink
Browse files

moving the location of the CORS headers

  • Loading branch information...
1 parent 757841e commit 71e601bfaf18b42fdb2e8be61285407394570af7 @aaronpowell committed Mar 25, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 web.js
View
8 web.js
@@ -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
@@ -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);
});
});

0 comments on commit 71e601b

Please sign in to comment.