Skip to content
This repository was archived by the owner on Aug 27, 2021. It is now read-only.
This repository was archived by the owner on Aug 27, 2021. It is now read-only.

CORS header incorrect #1417

@tcdevs

Description

@tcdevs

I have the same problem as @heycait on issue #370.

Im using the url https://api.sendgrid.com/api/mail.send.json with my custom AngularJS factory to send an email. This will work but i still get a CORS error. It will send the email accordingly.

This are the custom settings for the header in the AngularJS $http service:

headers: {
    'Content-Type': 'application/json' , 
    'Access-Control-Allow-Origin': 'http://sendgrid.com',
    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
    'Access-Control-Allow-Headers':'X-Requested-With'   
}

or with wildcard

headers: {
    'Content-Type': 'application/json' , 
    'Access-Control-Allow-Origin': '*',
    'Access-Control-Allow-Methods': 'POST, GET, OPTIONS',
    'Access-Control-Allow-Headers':'X-Requested-With'   
}

With both of the example headers i get the following error message:

Response to preflight request doesn't pass access control check: 
The 'Access-Control-Allow-Origin' header has a value 'https://sendgrid.com' 
that is not equal to the supplied origin. Origin 'http://192.168.0.25:8031' is 
therefore not allowed access.

The problem seems to be the 'Access-Control-Allow-Origin ' header on your domain need to be an wildcard instead of 'http://sendgrid.com'

Can this problem be fixed? Thanks for the help in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions