Default response header

30 views
Skip to first unread message

Rares Pop

unread,
May 21, 2012, 1:43:06 PM5/21/12
to narw...@googlegroups.com
Hi,

I apologize if this has been answered before, just couldn't find it anywhere.

I have jacks installed from narwhal and I'm using it for convenience in serving static and js files straight from the file system. 

Can anybody help me by telling what to change to make sure that the header Access-Control-Allow-Origin:* is contained in all http responses?

Thank you,
Rares

Kris Kowal

unread,
May 22, 2012, 12:43:30 PM5/22/12
to narw...@googlegroups.com
You’ll need a middleware like:

var CorsMiddleware = function (app) {
return function (request) {
var response = app(request);
response.headers = response.headers || {};
response.headers['access-control-allow-origin'] = '*';

return response;
};
}

Kris Kowal
Reply all
Reply to author
Forward
0 new messages