I’m going to post a little info here on more stuff I have found about CORS. However, I understand that you said you won’t fix this, and I’m totally fine with that. I’ll just make an intermediate server to allow myself to communicate with your REST api.
Anyways, here’s the additional info I found on MDN.
What requests use CORS?
This cross-origin sharing standard is used to enable cross-site HTTP requests for:
• Invocations of the XMLHttpRequest or Fetch APIs in a cross-site manner, …
• …
the XMLHttpRequest and the Fetch APIs are the only ways for javascript to communicate with external servers, so by not supporting CORS no other javascript application can use your REST api directly, only indirectly through other non-javascript servers.
Some snippets from this MDN article explains further what the CORS preflight check is.
A CORS preflight request is a CORS request that checks to see if the CORS protocol is understood.
It is an OPTIONS request …
A preflight request is automatically issued by a browser when needed; …
For example, a client might be asking a server if it would allow a DELETE request, before actually sending a DELETE request by using a preflight request: …
If the server allows it, then it will respond to the preflight request with a Access-Control-Allow-Methods response header response header that lists DELETE:
Which by the way, your server actually does return the correct Access-Control-Allow-Methods headers. Specifically your server gives me the following header:
Access-Control-Allow-Methods: POST, GET, PUT, DELETE, PATCH, OPTIONS
Its explained here that this header is specifically used in response to preflight (OPTIONS) requests to tell the client which request methods the server accepts. In other words, this header isn’t doing anything right now because preflight checks aren’t supported. (funny enough, this header is stating that the OPTIONS request is supported, even though it’s not).
The fact that the server is returning anything with Access-Control-Allow-* shows that an attempt was made to make the server work properly with CORS, as those headers are only used with CORS policies to my understanding.
By the way, while working on an intermediate server to communicate with yours, I found out that implementing the OPTIONS request in php is really as simple as die(). Any other language should be just as simple. As long as it returns the correct headers (which your server already seems to be doing), and the status code indicates no errors, then its implemented!
You mentioned that the Zammad web app works with the api just fine, and that would be expected, because its on the same domain as the api. CORS doesn’t apply when both resources are on the same domain.
So this really isn’t anything too specific to my setup or environment. In my first post I mentioned someone else on stackoverflow who was having the same problem with your REST api, and as far as I can tell, anyone who uses javascript would be unable to access your rest api directly, only indirectly through other servers.
However, if it is of value, my exact environment was shown above. I’m using Chrome 62.0.3202.94 and I pasted that javascript command into the browser and received a CORS error as shown in the screenshot. There’s nothing more to it, anyone should be able to get the same error by using the same javascript command in the browser.
Anyways, like I said, I’m totally cool with making another server to access your REST api, and in fact am already working on it, I just wanted to put this info out there. Also, as an unrelated side note, you still might want to look into why this 404 page is returning asp looking stuff.
Thanks for your help.