1

I'm using nginx on the remote server, and with no support for the OPTIONS method I've been terribly stuck. Both the server and angular refuse to talk to each other.

I just want to make a simple $http.post() request. Is there a way to configure the service to ONLY send the POST request, and not do any preflighting with OPTIONS?

Aditya M P
  • 5,127
  • 7
  • 41
  • 72

2 Answers2

3

This is not something AngularJS does, but something your browser does according to the Cross-Origin Resource Sharing standard. See also this answer on a related issue.

However, if you make it so that the AngularJS application is served from the same domain as your resource (different subdomains will affect cross-origin), then the browser will not send the OPTIONS request as the resource is no longer from a cross-origin server.

Example:

  • www.example.com requests resource on api.example.com will trigger OPTIONS request
  • www.example.com requests resource from www.example.com/api will not trigger OPTIONS request
Community
  • 1
  • 1
dagingaa
  • 91
  • 2
1

If CORS is Unavoidable You could change the header of the request to text/plain and then parse your response manually acording to answers in this link below

How to skip the OPTIONS preflight request in AngularJS

Community
  • 1
  • 1
Lelis718
  • 627
  • 7
  • 16