Answer the question
In order to leave comments, you need to log in
Why does yii2 cancel request and fire handleFatalError on CORS?
I am developing a service in Yii2 and AngularJS. Set up CORS.
.htaccess:
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Credentials true
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS, PATCH, HEAD"
Header set Access-Control-Allow-Headers "Authorization, Content-Type, Response-Type, If-Modified-Since"
Header set Access-Control-Expose-Headers "Content-disposition, X-Pagination-Current-Page, X-Pagination-Page-Count, X-Pagination-Per-Page, X-Pagination-Total-Count, Link"
</IfModule>
Answer the question
In order to leave comments, you need to log in
You cannot use AllowOrigin * in conjunction with AllowCredentials .
Either AllowOrigin * and no AllowCredentials , or AllowOrigin domain1 domain2 domainN along with AllowCredentials .
Mistake
has nothing to do with Yii, judging by your setup.
I'm not strong in Apache, but in my opinion mod_headers adds these headers of yours only in case of 200 response status, in any case, the documentation says this:
Try writing:Header always set Access-Control-Allow-Origin "*"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question