Skip to content

Instantly share code, notes, and snippets.

@ritch
Created August 26, 2012 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ritch/3482427 to your computer and use it in GitHub Desktop.
Save ritch/3482427 to your computer and use it in GitHub Desktop.
dpd custom resource for cross origin support
// this must be in your project's node_modules folder to be available from the dashboard
var Resource = require('deployd/lib/resource')
, util = require('util');
function CrossOrigin() {
Resource.apply(this, arguments);
// match all urls when routing
this.path = '/*';
}
util.inherits(CrossOrigin, Resource);
module.exports = CrossOrigin;
CrossOrigin.prototype.handle = function(ctx, next) {
ctx.res.setHeader('Access-Control-Allow-Origin', '*');
// hand the request to the next resource
next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment