Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 重定向时关闭iframe_Reactjs_Iframe_Xmlhttprequest_Fetch - Fatal编程技术网

Reactjs 重定向时关闭iframe

Reactjs 重定向时关闭iframe,reactjs,iframe,xmlhttprequest,fetch,Reactjs,Iframe,Xmlhttprequest,Fetch,我在模态中有一个iframe const ThreeDSecure = ({ paymentRequest, md, termUrl, issuerUrl, source, promotions, products, userProfile }) => { const dispatch = useDispatch(); const formId = `${source}-form`; window.ad

我在模态中有一个iframe

const ThreeDSecure = ({
    paymentRequest,
    md,
    termUrl,
    issuerUrl,
    source,
    promotions,
    products,
    userProfile
}) => {
    const dispatch = useDispatch();
    const formId = `${source}-form`;
    window.addEventListener(
        'message',
        function(event) {
           ...
        },
        false
    );
    
    const submitForm = () => {
        setTimeout(() => {
            if (document.forms[formId]) {
                document.forms[formId].submit();
            }
        }, 100);
    };
    
    return (
        <ThreeDSecureModal
            renderBodyContent={() => (
                <iframe
                    height="500"
                    width="100%"
                    name="threeDSiFrame"
                    title="threeDSiFrame"
                    frameBorder="0"
                    onLoad={submitForm()}
                >
                    <form
                        action={issuerUrl}
                        id={formId}
                        method="POST"
                        target="threeDSiFrame"
                    >
                        <input
                            type="hidden"
                            name="loadReq"
                            value={loadReq}
                        />
    
                    </form>
                </iframe>
            )}
        />
    );
在my
submitForm()
中使用以下代码:

但它抛出了CORS错误:

Access to fetch at 'https://checkoutshopper-test.adyen.com/checkoutshopper/threeDS2.shtml' from origin 'https://checkout.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
有没有办法解决这个问题,因为银行不会把我们列入白名单

fetch(issuerUrl, {
        method: 'POST',
        body: new FormData(document.forms[formId]),
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
    })
    .then(res => res.text())
Access to fetch at 'https://checkoutshopper-test.adyen.com/checkoutshopper/threeDS2.shtml' from origin 'https://checkout.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.