Can't use "Options" in Post Call - Is there a way around this?


#1

All,

I’m getting the following message (on the server side) when I do a post in Ionic 2:

Authentication method not supported: OPTIONS.

the call I’m using is:

this.http.post('https://mobile-qa.company.org/webapp/j_security_check', body, options)

Is there a way to pass my headers into the post call without using the options parameter, or am I missing something?

Any help would be appreciated!

Jai


Http Post on Ionic?
#2

OPTIONS is the request method in this case.

For security reasons (“CORS” is the term to google) the browser sometimes does this “preflight request” first before he actually contacts the real URL: https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/OPTIONS#Preflighted_requests_in_CORS

You will have to implement this OPTIONS request in your backend.


#3

I don’t have any control of the backend - How can I work around this? Is there a way to send the headers that doesn’t require an OPTIONS call?


#4

Contact whoever does have control of the backend, especially if they’re claiming to be providing security testing services, and tell them that they need to implement CORS properly.


#5

No, but you can proxy these requests through your own server where you take care of the headers. That’s not the right solution, but it works. If you google for “CORS proxy” you might find ready made software or even hosted ones for development.