Skip to content

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

@dylanmensaert

Description

@dylanmensaert

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions