-1

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

enter image description here

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

enter image description here

Malki Mohamed
  • 1,052
  • 1
  • 15
  • 34

1 Answers1

0

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.

antoiba86
  • 78
  • 9
  • @Antobla, Thank yous, But still not working I gote the same error – Malki Mohamed Oct 14 '19 at 12:22
  • @MalkiMohamed could you try to make the request via Postman? It is strange that status code "301" – antoiba86 Oct 14 '19 at 13:41
  • @Antobla, from postman it works fine, I think its something related with a virtual host, this is how I create it ` DocumentRoot "C:/PATH_TO_PROJECT_FOLDER/public" ServerName cappoffshore.ms.local ` – Malki Mohamed Oct 14 '19 at 14:00