I have 2 domains.
I try to open a URL from domain 2 in domain 1 using window.open
JavaScript tag and after the user does some staff on domain 2 then put the result in a div on domain 1 using window.opener
everything works fine but at the final step, I get cross-origin error Uncaught DOMException: Blocked a frame with origin "http://example.com" from accessing a cross-origin.
in chrome console.
How to allow access to a cross-origin on domain 1 in PHP?
EDIT
My question is not a possible duplicate of this question because I'm asking about PHP.
SOLUTION
Just add header("Access-Control-Allow-Origin: *");
at the beginning of your code after opening PHP tag, this will allow access from any origin (website).
if you want to limit the access, replace *
with origin (website) url like header("Access-Control-Allow-Origin: http://example.com/");