I am creating an app with larvel and vue js. It is in two separate directories. one is larvel and vue js and the other is vue. I am trying to access some apis from vue.js directory located at the second directory. On local it was working fine but on go daddy server it says:
Chrome: Access to XMLHttpRequest at 'https://maindirectory(larvel)' from origin 'https://(second directory)vue.js' 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.
On Firefox it says: Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://directory1/api/seller/login. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing). Status code: 403.
I have tried almost every solution available on the internet: i have placed these headers:
header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Authorization, Content-Type, X-Authorization,X-CSRF-Token,api_token'); header('Access-Control-Expose-Headers: X-Authorization, Authorization'); header('Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE');
In routes.php , api.php and also tried setting headers in web.config and .htaccess.
But nothing helped. I have been stuck for four days. Any help would be appreciated.