SimonAngatia's avatar

Setting allow CORS headers in Laravel

I am working with an API that requires me to embed their games lobby into an iFrame on the website I am working on. I realized that the lobby interacts with my website by sending messages to it. Now the problem is that on rendering the iFrame, it doesn't show anything but a blank page. However, on checking the console, I get this error: Uncaught DOMException: Blocked a frame with origin "https://website.co" from accessing a cross-origin frame.

Meaning that my page is blocking the domain in the iFrame from accessing the main window where the iFrame is contained. On doing research, I found out that you can have control over this if you have control of the domain in the iframe src. In my case though I don't have control over it. I also came across a resource talking of setting headers in my Laravel app to add the domain in the URL into the list of allowed origins. However, I have no idea how to go about this in Laravel. Could anyone help me get a hint on how to go about this?

My html file:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">

</head>
<body>
<div class="container"> 
<iframe class="responsive-iframe" src="{{$FULL_URL}}"  style="border: 0; position:fixed; top:0; left:0; right:0; bottom:0; " allowfullscreen></iframe>

</div>



</body>
</html>

enter image description here

0 likes
0 replies

Please or to participate in this conversation.