Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dylanmensaert opened this issue Aug 29, 2017 · 0 comments
Open

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

dylanmensaert opened this issue Aug 29, 2017 · 0 comments

Comments

@dylanmensaert
Copy link

dylanmensaert commented Aug 29, 2017

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?

@dylanmensaert dylanmensaert changed the title Add headers to response? Add headers to response or enable CORS? Aug 29, 2017
@dylanmensaert dylanmensaert changed the title Add headers to response or enable CORS? Header 'Allow: GET, HEAD, OPTIONS' being added. Aug 29, 2017
@dylanmensaert dylanmensaert changed the title Header 'Allow: GET, HEAD, OPTIONS' being added. Response header getting overwritten. Aug 29, 2017
@dylanmensaert dylanmensaert changed the title Response header getting overwritten. 'Allow: GET, HEAD, OPTIONS' header being added unwillingly Aug 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant