Skip to content

HTTP 'options' requests #16

Open
Open
@codeuniquely

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();
});

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