'Yii2 form "Unable to verify your data submission" while loading from an external iframe

i have a yii2 project having a signup page.So i am working on another project having an iframe.Now i want to load my forms in that external iframe.

const iframe_container=document.getElementById("iframe-container");

var iframe = document.createElement('iframe');
iframe.src = "http://127.0.0.1/personal/proj/frontend/web/index.php?r=site%2Fsignup";

iframe_container.appendChild(iframe);

Please check the above code. But i am getting the following error while submitting the form

Bad Request (#400)
Unable to verify your data submission.

I know this is a csrf issue.Then i did inspect on the iframe , then i can see the csrf token there.So the issue will be its not validating..

How can i fix this issue



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source