How can I fetch the content of a post of my wordpress domain from an other domain?

Question

I have my wordpress website, let’s say wp.com, and an other domain, let’s call it js.com.

I would like to allow GET queries coming from the javascript client code of js.com to wp.com.

Something like:

File main.js hosted under js.com:

$.get("wp.com/my-post", function(...) {... } )

I looked up different information on Google and it seems that I have to edit the .htaccess on wp.com to enable js.com.

I looked at:

But now I am not sure what to set up.

The Header set Access-Control-Allow-Origin "*" is scaring me. I am worried any website will be able to fetch data from my website instead of only js.com.

I am also confused between somewebsite talking about HTTP header vs setting up .htaccess vs setting files name vs subdomain.

I just want to open some get request. I don’t care about the specific files. I want to be able to receive the HTML of my page on this other domain.

0
Wonay 5 months 0 Answers 63 views 0

Leave an answer