samedi 30 décembre 2017

Laravel 5.3 CORS with JWT auth

I have an issue with Laravel 5.3 CORS. I searched a lot on this issue, and found many recommending barryvdh for CORS. This however didn't work, and I found people mentioning that this could be caused by the use of tymondesigns jwt-auth module. Some suggests bypassing it by setting

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Authorization, Content-Type');

in the api.php file. This results in responses like:

Failed to load http://ift.tt/2CdcikD: Method PUT is not allowed by Access-Control-Allow-Methods in preflight response.

In attempt to resolve this issue I added

header('Access-Control-Allow-Methods: POST, GET, OPTIONS, DELETE, PUT');

to the above 2 lines. However this left me with a new issue:

PUT http://ift.tt/2CdcikD 403 (Forbidden)
Failed to load http://ift.tt/2CdcikD: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://example.com' is therefore not allowed access. The response had HTTP status code 403.

Any suggestions how to go about this?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2BZo9yt
via IFTTT

Aucun commentaire:

Enregistrer un commentaire