You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 14, 2022. It is now read-only.
I just ended up creating a fitting to handling the verbs based off of swagger definition
const _ = require('lodash');
const verbWhitelist = ["get", "post"];
// Used for CORS preflight options by path.
module.exports = function create(fittingDef, bagpipes) {
return function corsVerbs(context, cb) {
// If not options, go to next controller
if (context.request.method !== 'OPTIONS') return cb(null, context);
let verbs = _.pick(context.request.swagger.path, verbWhitelist);
let responseVerbs = Object.keys(verbs).map(function (x) { return x.toUpperCase() });
if (responseVerbs.indexOf('OPTIONS') === -1) responseVerbs.push('OPTIONS');
context.response.set('Access-Control-Allow-Methods', responseVerbs.join(','))
context.response.status(204).send();
};
};
Is there any documentation regarding CORS preflight requests? Seems like these should automatically be configured based on the swagger definition.
I'm looking to return the verbs defined in swagger for my resources (paths) but I can't even find how to control "preFlightContinue" option.
Thanks in advance.
The text was updated successfully, but these errors were encountered: