Open SWS-5007 opened 1 year ago
I am deploying the Laravel Backend on Vercel. And Vue Frontend is deployed on Netlify. Now I am getting CORS Error like below:
Access to XMLHttpRequest at 'https://businesscard-backend.vercel.app/api/getInfos' from origin 'https://businesscard-frontend.netlify.app' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
Here is my Vercel.json file of Laravel.
Vercel.json
{ "version": 2, "functions": { "api/index.php": { "runtime": "vercel-php@0.5.2" } }, "routes": [{ "src": ".*", "dest": "/api/index.php", "headers": { "Access-Control-Allow-Origin": "https://businesscard-frontend.netlify.app", "Access-Control-Allow-Headers": "Origin, X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version", "Access-Control-Allow-Methods": "GET,OPTIONS,PATCH,DELETE,POST,PUT", "Access-Control-Allow-Credentials": "true", "Access-Control-Allow-PreflightContinue": "true", "Access-Control-Allow-OptionsSuccessStatus": "200" }, "continue": true }], "headers": [{ "source": ".*", "headers": [{ "key": "Access-Control-Allow-Credentials", "value": "true" }, { "key": "Access-Control-Allow-Origin", "value": "https://businesscard-frontend.netlify.app" }, { "key": "Access-Control-Allow-Methods", "value": "GET,OPTIONS,PATCH,DELETE,POST,PUT" }, { "key": "Access-Control-Allow-Headers", "value": "X-CSRF-Token, X-Requested-With, Accept, Accept-Version, Content-Length, Content-MD5, Content-Type, Date, X-Api-Version" } ] }], "env": { "APP_NAME": "BusinessCard-Backend", "APP_ENV": "production", "APP_DEBUG": "false", "APP_CONFIG_CACHE": "/tmp/config.php", "APP_EVENTS_CACHE": "/tmp/events.php", "APP_PACKAGES_CACHE": "/tmp/packages.php", "APP_ROUTES_CACHE": "/tmp/routes.php", "APP_SERVICES_CACHE": "/tmp/services.php", "VIEW_COMPILED_PATH": "/tmp", "CACHE_DRIVER": "array", "LOG_CHANNEL": "stderr", "SESSION_DRIVER": "cookie", "VIEW_COMPILED_PATH": "/tmp/views", "SSR_TEMP_PATH": "/tmp/ssr", "NODE_PATH": "node" } }
What is Wrong? How can I solve this problem?
I am deploying the Laravel Backend on Vercel. And Vue Frontend is deployed on Netlify. Now I am getting CORS Error like below:
Here is my
Vercel.json
file of Laravel.What is Wrong? How can I solve this problem?