I have a PHP API that sends JSON.
Whenever I try to fetch that JSON I get:
My .htaccess file looks like this:
I'm completely stumped on how to allow the fetch to actually fetch, any suggestions?
I have a PHP API that sends JSON.
Whenever I try to fetch that JSON I get:
My .htaccess file looks like this:
I'm completely stumped on how to allow the fetch to actually fetch, any suggestions?
Your 2nd and 3rd screenshots indicate that you're adding an Access-Control-Allow-Origin
header to the request. However, that header is a response header, not a request header; adding it to a request is pointless and counterproductive. Moreover, because it isn't listed in the value of your Access-Control-Allow-Headers
header. Therefore, CORS preflight fails.
Besides, your 4th screenshot indicates that you're explicitly allowing the Origin
header, but there's never a need for that, because that header is special and automatically added by the browser.
Stop sending an Access-Control-Allow-Origin
header with your requests.
You can also drop Origin
from the Access-Control-Allow-Headers
header in your CORS configuration.