[Vuejs]-Laravel7 CORS : blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin'

0👍

I had got the same CORS error while working on a Vue.js project. I finally solved this issue just today in the morning. You can resolve this either by building a proxy server or another way would be to disable the security settings of your browser (eg, CHROME) for accessing cross origin apis. Both these solutions had worked for me. The later solution is the easiest solutoion and does not require any mock server or a proxy server to be build. Both these solutions can be resolved at the front end.

You can disable your browser (CHROME) security settings for accessing apis out of the origin by typing the below command on the terminal:

/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome –user-data-dir=”/tmp/chrome_dev_session” –disable-web-security

After running the above command on your terminal, a new chrome window with security settings disabled will open up. Now, run your program (npm run serve / npm run dev) again and this time you will not get any CORS error and would be able to GET request using axios.

Hope this helps!

Leave a comment