Franky Diaz-Trepat
Franky Diaz-Trepat

Reputation: 31

angular OPTIONS http preflight on "Same Domain"?

I am currently confused about how angular's (jquery) preflight OPTIONS call is "selected" or chosen to perform before a request.

I have a normal RESTful api call (api.domain.co)

I have created a host entry 127.0.0.1 local.domain.co in my hosts file /etc/hosts.

I've created self-signed certificate:

http://www.akadia.com/services/ssh_test_certificate.html

I've configured the certs in my mac as trusted:

http://abetobing.com/blog/port-forwarding-mac-os-yosemite-81.html

I've configured my Yosemite Port Forwarding Rules:

http://abetobing.com/blog/port-forwarding-mac-os-yosemite-81.html

I understand that from the browser's perspective (Chrome):

I have an angular app being loaded from https://local.domain.co with a trusted certificate that has a call to https://api.domain.co/user everything looks green with the cert, and I still get a preflight OPTIONS call to my api.domain.co server which is a node resitfy server with CORS support

Everything is Working... BUT

I want to get rid of the OPTIONS preflight Any pointers?

Upvotes: 3

Views: 1492

Answers (2)

Jeffrey A. Gochin
Jeffrey A. Gochin

Reputation: 964

You can't use localhost. I had to create an entry in my host file to associate 127.0.0.1 to an arbitrary name like mackbook. Then it should work for you.

Upvotes: 0

kwangsa
kwangsa

Reputation: 1711

unfortunately subdomain still affected by preflight rule so if you want to remove OPTIONS you can either using jsonp or have the same subdomain for both the site & api.

Upvotes: 1

Related Questions