L
L
lemonboss2019-06-06 21:32:52
AJAX
lemonboss, 2019-06-06 21:32:52

The post request to the subdomain (Access-Control-Allow-Origin) with safari does not pass, how to solve the problem?

The task is this.
There are for example ajax requests with content type json. They happen in the following order. First, there is a request with the OPTIONS type where the parameters are passed to be checked by the server. And then there is the request itself with these parameters.
So. The problem is this, only in safari, the first request with the OPTIONS type does not work. Throws an error that the type for the request is not valid. Although there are rules for such types
->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS')
Yes, and it works in other browsers (in all)
What could be the reason for this. Any thoughts will help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
grinat, 2019-06-06
@grinat

Remove the type content and options won't go away. Per content type, Safari is right:
A header is said to be a simple header if the header field name is an ASCII case-insensitive match for Accept, Accept-Language, or Content-Language or if it is an ASCII case-insensitive match for Content-Type and the header field value media type (excluding parameters) is an ASCII case-insensitive match for application/x-www-form-urlencoded, multipart/form-data, or text/plain.
https://www.w3.org/TR/cors/#simple-header

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question