From 4f458a730605587fdba20c5106c681acdb174bcf Mon Sep 17 00:00:00 2001 From: "wkylin.w" Date: Sun, 21 Jul 2024 18:06:14 +0800 Subject: [PATCH] feat: postmessage --- .env.production | 2 +- src/pages/postmessage/index.jsx | 2 +- src/pages/postmessage/myIframe/index.jsx | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.env.production b/.env.production index abe8e16d..c0b196c5 100644 --- a/.env.production +++ b/.env.production @@ -9,4 +9,4 @@ AUTH_PASSWORD=wkylin.w # github pages # PUBLIC_URL='/pro-react-admin' PUBLIC_URL='' -IFRAME_ORIGIN=https://wkylin.github.io/pro-react-admin \ No newline at end of file +IFRAME_ORIGIN=https://wkylin.github.io \ No newline at end of file diff --git a/src/pages/postmessage/index.jsx b/src/pages/postmessage/index.jsx index 4064c8a5..cdc5d144 100644 --- a/src/pages/postmessage/index.jsx +++ b/src/pages/postmessage/index.jsx @@ -2,7 +2,7 @@ import React, { useRef, useEffect } from 'react' const PostMessage = () => { const origin = process.env.IFRAME_ORIGIN - const childOrigin = `${process.env.IFRAME_ORIGIN}/#/my-iframe` + const childOrigin = `${process.env.IFRAME_ORIGIN}/pro-react-admin/#/my-iframe` const ref = useRef() const onReceivedMessage = (event) => { diff --git a/src/pages/postmessage/myIframe/index.jsx b/src/pages/postmessage/myIframe/index.jsx index 180cd633..b59dc6ee 100644 --- a/src/pages/postmessage/myIframe/index.jsx +++ b/src/pages/postmessage/myIframe/index.jsx @@ -6,6 +6,8 @@ const MyIFrame = () => { const onReceivedMessage = (event) => { // check the message source origin as a security measure + console.log('event.origin', event.origin) + console.log('parentOrigin', parentOrigin) if (event.origin !== parentOrigin) { return }