Q: Access to XMLHttpRequest at 'http://site.local/api/v1/profiles' from origin 'http://localhost:4200' has been blocked by CORS policy: I've a problem when I try to get data from this endpoint http://cappoffshore.ms.local/api/v1/profiles (virtual host). But it working when I used this endpoint http://localhost:8000/api/v1/profiles (got it via php artisan serve).
I tried many solution like:
stackoverflow.com/questions/35588699/response-to-preflight-request-doesnt-pass-access-control-check#35588856
stackoverflow.com/questions/53528643/cross-origin-resource-sharing-cors-in-angular-or-angular-6-problem-while-you/53528644#53528644
But that still not working for me.
This is what I got for those endpoint :
using http://localhost:8000

using  http://cappoffshore.ms.local virtual host:


A: I run into this problem many times. CORS policy is a delicated issue.
I always install in my projects this package via composer.
https://github.com/barryvdh/laravel-cors
In Laravel you allow to receive request from different domains with this package. Maybe it is the solution you are looking for.
