[Vuejs]-Is there any way to fix CORS api calls from Laravel to a nodejs/expressjs client?

1👍

install the package of cors in node.js /express.js

-1👍

The message says that x-crsf-token header arent suppprted in the express app. You should add it on your express app. Or disable preflight in cors.

-1👍

As the x-csrf-token is blocked by CORS policy. You have to add the Access-Control-Allow-Headers in the index.php file in laravel which you will find in public folder .That will solve your problem. Now paste the following lines in index.php file in laravel.

header('Access-Control-Allow-Origin: *');  
header('Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Content-Type, X-XSRF-Token, Origin');

I hope this will solve your problem

Leave a comment