I am pulling posts from one WordPress website to another. Both websites are on same server. For pulling posts i am using jQuery.ajax with Rest API. But i am getting error message in console
Access to XMLHttpRequest at 'https://www.website1.com/wp-json/wp/v2/posts/?tags=4,198&per_page=24&offset=1&_embed' from origin 'https://website2.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
For this i have added following header
Header set Access-Control-Allow-Origin "*"
In .htaccess of both websites. Also i have used this
crossDomain: true,
In ajax. But still having error. Any help. Please