1

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.

1

editing the .htaccess file on wp.com with :

Header add Access-Control-Allow-Origin: "https://js.com"
Header add Access-Control-Allow-Methods: "GET"
Header add Access-Control-Allow-Headers: "Upgrade-Insecure-Requests"

works

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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