express request options code example
Example: express getting options instead of post
// 'OPTIONS' is a standard request send by browsers BEFORE your request
// Your server needs to handle these requests appropriately
// Please see source and upvote the answer I got this from to share credit
var express = require('express')
, cors = require('cors')
, app = express();
const corsOptions = {
origin: true,
credentials: true
}
app.options('*', cors(corsOptions)); // preflight OPTIONS; put before other routes
app.listen(80, function(){
console.log('CORS-enabled web server listening on port 80');
});