vendredi 1 mars 2019

Angular CORS policy with server?

It is typical error, that happens frequently. I have explored solutions and have added settings to server in middleware level:

  return $next($request)
        ->header('Access-Control-Allow-Origin', '*')
        ->header('Access-Control-Allow-Methods', 'GET, POST, PUT, DELETE, OPTIONS');

Then I ask localhost server endpoints from localhost client, only are different ports.

It still swears such as:

list:1 Access to XMLHttpRequest at 'http://localhost:8000/api/' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

In server response I see headers:

Access-Control-Allow-Origin →*
Access-Control-Allow-Methods →GET, POST, PUT, DELETE, OPTIONS



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire