1

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

1 Answer 1

0

just write this on your function.php

add_filter( 'allowed_http_origin', '__return_true' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.