No ‘Access-Control-Allow-Origin’ when call rest API

Question

I am using ReactJs with WordPress. WordPress running on localhost 8888 port and React app running on 3000 port. When I change the WordPress site URL (from settings->general) to localhost:300 then I am getting the following error,

Access to XMLHttpRequest at
http://localhost:8888/bolb/wp-json/wp/v2/categories‘ from origin
http://localhost:3000‘ has been blocked by CORS policy: No
‘Access-Control-Allow-Origin’ header is present on the requested
resource.

It’s not working on the postman too. But, it’s okay if I use the same URL (http://localhost:8888/bolb) as the site URL.

enter image description here

--------------------------------------------------

>>> Share a link to this question, just copy and paste the code bellow on your web page <<<

<a href="https://www.wptricks.com/question/no-access-control-allow-origin-when-call-rest-api/">

No 'Access-Control-Allow-Origin' when call rest API</a>
0
, sonjoy.dat 3 weeks 0 Answers 40 views 0

Leave an answer