Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

What is CORS and How to Handle it?

Premium
2 min read

Now, let's talk about Cross-Origin Resource Sharing (CORS). It seems like a very complicated topic. You can read about it in the developer.mozilla.org, but I will try to summarize it in the shortest possible way.

By default, in Laravel, you don't need to change anything, but you need to understand where to look if something goes wrong.


CORS isn't a Laravel or a PHP thing. It's how the browsers work. By default, if you try to open one resource from another domain resource, it's usually about web domains, you may run into a CORS error:

In Laravel, CORS settings are set in the config/cors.php file; by default, it allows everything.

I have cloned the same Vue.js project into a different directory. So now, I have project.test as a frontend and demo.test as an API. I changed the API call to use...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (31 h 16 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

�G
Łukasz Gołko ✓ Link copied!

i dont have the following file in my laravel 12 app

config/cors.php

N
Nerijus ✓ Link copied!

All config files can be published

�G
Łukasz Gołko ✓ Link copied!

what?

N
Nerijus ✓ Link copied!

All config files can be published whet it's from a package or a framework itself via an artisan command.

php artisan config:publish
�G
Łukasz Gołko ✓ Link copied!

this is even written in this article... xD i am really blind xD thanks a lot :*