#How do i configure cors?

35 messages · Page 1 of 1 (latest)

hazy rose
#

this is what i found in an article, but i do not have kernel.php

smoky violet
hazy rose
#

uhh am i supposed to do it like this?

smoky violet
#

Yes, that's how you configure your CORS rules

hazy rose
#

weird im still getting this

smoky violet
#

IIRC you'd need to set the SANCTUM_STATEFUL_DOMAINS env value if you have it specified

hazy rose
#

yeah i do

smoky violet
#

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.

hazy rose
#

trying everything I can haha

#

should i just use laravel 10

wraith island
#

Are you feching the root path? That's not listed in the paths in your config

hazy rose
#

didnt work :'

#

but i can access it through the browser tho

#

but making a fetch call in my js app doesnt work...

smoky violet
# hazy rose so like this?

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.

hazy rose
#

thanks

#

still no luck tho haha

#

btw do i configure root paths like this?

smoky violet
#

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

hazy rose
#

okay okay i changed it back

#

still doesnt work

hazy rose
wraith island
#

What are you showing us? Where's that image from?

hazy rose
#

this one is from my js application, failing an api call

wraith island
#

In the browser? Or a JS server application?

#

I don't see how ECONNREFUSED and CORS are related

hazy rose
#

browser is saying this

hazy rose
# hazy rose

my js application is saying econnrefused.
thats because cors is blocking it

wraith island
#

That error message is very clear, you are getting '*' but it's not valid