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:
- https://www.moxio.com/blog/12/how-to-make-a-cross-domain-request-in-javascript-using-cors
- https://wordpress.org/support/topic/activating-cors/
- https://crunchify.com/how-to-fix-access-control-allow-origin-issue-for-your-https-enabled-wordpress-site-and-maxcdn/
- and installed the plugin named
WP Htaccess Editor
onwp.com
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.