Answer the question
In order to leave comments, you need to log in
"CORS preflight channel failure" - how to solve?
Good afternoon.
The following headers have been added to .htaccess:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Allow-Headers "append,delete,entries,foreach,get,has,keys,set,values,Authorization"
</IfModule>
Request from foreign origin blocked: The single origin policy prohibits reading the remote resource on site.api. (Reason: CORS preflight channel failure).
Request from foreign origin blocked: The single origin policy prohibits reading the remote resource on site.api. (Reason: CORS request failed).
Answer the question
In order to leave comments, you need to log in
preflight requests are made from another host and the method is OPTIONS.
In general, you have everything written correctly and the check will depend on where and how you host the service. In general, the steps are as follows:
1. If you write these directives in .htaccess, then make sure that you have AllowOverride All set in /etc/apache2 configs and .htaccess is picked up.
2. Make sure you have mod_headers enabled by running the a2enmod headers command.
3. Use, for example, https://www.test-cors.org/ to check if access has been granted.
If you have this on shared hosting and you cannot follow these steps, contact technical support with your question on how to solve this problem.
Good luck in solving the issue)
Sincerely,
Ivan Tomilov
CEO of Athanor
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question