How can we avoid option call in edge micro from an webapp

How can we avoid OPTION call in microgateway. or how do we fix this CORS in microgateway. The backend is capable of handling the CORS call. but the OPTION call is failing in apikey authentication itself in microgateway if apikey is passed in header, as OPTION call doesn't pass the header parameter. So I pass the apikey in query and it works fine, but the problem with this solution is the quota plugin for this proxy. every OPTION call is also consuming the quota which is wrong. so if I am having a 10 request per day quota. if I am hitting from a web application, I am only able to hit 5 API calls because of 5 OPTION call for each 5 POST calls. so I need to avoid the quota plugin also for OPTION call

Solved Solved
0 4 260
1 ACCEPTED SOLUTION

Former Community Member
Not applicable

@krushna.padhee.ap

You'll have to implement a custom plugin to handle this. Make sure the custom plugin appears BEFORE the oauth plugin in the config.yaml file.

View solution in original post

4 REPLIES 4

Former Community Member
Not applicable

@krushna.padhee.ap

You'll have to implement a custom plugin to handle this. Make sure the custom plugin appears BEFORE the oauth plugin in the config.yaml file.

Hi Sridhar,

Even though I create a custom plugin, I think it will fail in apikey and quota validation. because if we don't ignore apikey and quota plugin for OPTION method, it will fail. so the question is how to ignore these two steps for OPTION method.

Former Community Member
Not applicable

If you return from the plugin then no other plugins are executed. For ex:

'use strict';
module.exports.init = function(config, logger, stats) {    return {   onrequest: function(req, res, next) {            if('OPTION' == req.method)        res.end('OK')      else        next()    }  }}

NOTE: Obviously you don't want to send 'OK'. You'd want to set the http headers (allow origin etc.). But returning here, no other plugin is executed.

Hi Sridhar,

I have created a custom plugin in similar lines. It is working fine. Thanks a lot for your input