Skip to content


add HTTP OPTIONS handler in CORS example #1398

bodokaiser opened this Issue · 1 comment

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', '');
    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 {


Regards, bodo

@tj tj closed this in 4283f38
tj commented

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
Something went wrong with that request. Please try again.