#How do i configure cors?
35 messages · Page 1 of 1 (latest)
https://laravel.com/docs/11.x/routing#cors
You're likely looking at Laravel 10 guides, lots changed in Laravel 11. I'd recommend to look through the docs instead.
uhh am i supposed to do it like this?
Yes, that's how you configure your CORS rules
weird im still getting this
IIRC you'd need to set the SANCTUM_STATEFUL_DOMAINS env value if you have it specified
yeah i do
Okay so I missed it, but you're accessing them on different domains. One is at 127.0.0.1 and the other is at localhost, those are different. You need to use the same domain. So either just use localhost for all things, or use the IP, not mix both.
Are you feching the root path? That's not listed in the paths in your config
so like this?
didnt work :'
but i can access it through the browser tho
but making a fetch call in my js app doesnt work...
No, he means, in your CORS config you only have api/* and sanctum/csrf-cookie as paths, so if you're making a request to just /, that won't go through the CORS config.
Now you're accessing another different URL
It's really difficult to follow if you keep changing random things without knowing what you're really doing
my paths are these now, i have root configured in
What are you showing us? Where's that image from?
this one is from my js application, failing an api call
In the browser? Or a JS server application?
I don't see how ECONNREFUSED and CORS are related
browser is saying this
That error message is very clear, you are getting '*' but it's not valid