drewzboto / grunt-connect-proxy

Grunt Connect support for proxying API calls during development
MIT License
423 stars 122 forks source link

'Allow: GET, HEAD, OPTIONS' header being added unwillingly #145

Open dylanmensaert opened 7 years ago

dylanmensaert commented 7 years ago

I try to enable CORS via middleware option by adding extra headers to the response. My code for this is:

                    middleware: function (connect, options, middlewares) {
                        middlewares.unshift(function(req, res, next) {
                            res.setHeader('Access-Control-Allow-Origin', '*');
                            res.setHeader('Access-Control-Allow-Methods', '*');

                            return next();
                        });

                        return middlewares;
                    }

This works correctly, but an extra header is being added also which makes the response invalid. The header being added is Allow: GET, HEAD, OPTIONS.

I tried to add code to the unshift method to remove this header, namely res.removeHeader('Allow');, but it does not seem to work.

Any suggestions?