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

CORS Support #4

Open
singh1469 opened this issue Aug 19, 2014 · 3 comments
Open

CORS Support #4

singh1469 opened this issue Aug 19, 2014 · 3 comments

Comments

@singh1469
Copy link

Is CORS actually supported by this repo ?, because my CORS requests straight from the browser are not being honoured.

Use Case
I'm using the apostle.js repo together with superagent to deliver email. This is a CORS request directly from the browser.

Code

function testApostle(){
    apostle.domainKey = 'my-key-here';
    apostle.deliver('template_name', {
        email: '[email protected]'
    });
}

superagent throws the following error:
XMLHttpRequest cannot load https://deliver.apostle.io/. Request header field Apostle-Client is not allowed by Access-Control-Allow-Headers.

Superagent
Superagent requires all CORS request to adhere to the following:
The .withCredentials() method enables the ability to send cookies from the origin, however only when "Access-Control-Allow-Origin" is not a wildcard ("*"),
Reference - superagent

The network request initiated by Apostle.io and executed by superagent returns the following header (amongst others) from https://delivery.apostle.io:
Access-Control-Allow-Origin:*

Is this a known issue?
is the Apostle.io library therefore not CORS compatible?

@snikch
Copy link
Member

snikch commented Aug 19, 2014

Cors is supported, but it looks like an extra header that was added in to identify requests is preventing it from working as expected. We'll get the Apostle-Client header added to Access-Control-Allow-Headers and comment here when complete.

@snikch
Copy link
Member

snikch commented Aug 19, 2014

Ok, the deliver endpoint should now accept the Apostle-Client header for CORS requests. Let me know how it goes!

@singh1469
Copy link
Author

Fixed. Thank you very much.

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

2 participants