Created
August 26, 2012 18:38
-
-
Save ritch/3482427 to your computer and use it in GitHub Desktop.
dpd custom resource for cross origin support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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