Skip to content

HTTP 'options' requests #16

Description

@codeuniquely

Would it be possible to add routing for OPTIONS

POST, GET, PUT, PATCH, DELETE and ANY already exist but the ability to deal with a "pre-flight" OPTIONS request explicitly, would be very useful, like this maybe:

route.options('*', function(req,res) {
  var headers = {};
  headers["Access-Control-Allow-Origin"] = "*";
  headers["Access-Control-Allow-Methods"] = "POST, GET, PUT, DELETE, OPTIONS";
  headers["Access-Control-Allow-Credentials"] = true;
  headers["Access-Control-Max-Age"] = '86400'; // 24 hours
  headers["Access-Control-Allow-Headers"] = "X-Requested-With, Access-Control-Allow-Origin, X-HTTP-Method-Override, Content-Type, Authorization, Accept";

  // respond to the request
  res.writeHead(200, headers);
  res.end();
});

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions