I am trying to access a cross-origin page in my development environment using an iframe.
Here's the host page that is served by Express js at http://localhost:5000. It has an embedded iframe that's trying to access a React app running at http://localhost:3000.
<!DOCTYPE html>
<html>
<body>
<h1>Host Page</h1>
<iframe
id="child"
src="http://localhost:3000"
scrolling="no"
sandbox="allow-popups allow-scripts allow-same-origin"
style="width: 1px; min-width: 100%; border-width: 0;"
></iframe>
</body>
</html>
However when this page comes up, the iframe shows the following error:
SecurityError: Blocked a frame with origin "http://localhost:3000" from accessing a cross-origin frame.
What's the easiest way to make this work? This is just for my local development - no security concerns whatsoever!