Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

add HTTP OPTIONS handler in CORS example #1398

bodokaiser opened this Issue Nov 4, 2012 · 1 comment


None yet
2 participants


when using CORS the browser tries to do a OPTIONS request to check cross domain policy. This is not handled from express itself and it would be helpful if you add it to you example.

app.all('*', function(req, res, next) {
    res.header('Access-Control-Allow-Origin', 'http://node.enabre.com:3000');
    res.header('Access-Control-Allow-Methods', 'HEAD, GET, POST, PUT, DELETE, OPTIONS');
    res.header('Access-Control-Allow-Headers', 'Content-Type, X-Requested-With, Origin, Accept');
    res.header('Access-Control-Allow-Credentials', 'true');

    if (req.method.toLowerCase() === 'options') {
    } else {

source: http://stackoverflow.com/questions/13218174/cors-put-not-found-with-jquery-ajax

Regards, bodo

@tj tj closed this in 4283f38 Nov 4, 2012


tj commented Nov 4, 2012

thanks! oddly it does work fine when 404ing for me in chrome at least but certainly not reason to next() there anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment