Skip to content

Commit

Permalink
feat: postmessage
Browse files Browse the repository at this point in the history
  • Loading branch information
wkylin committed Jul 21, 2024
1 parent 089cec7 commit 4f458a7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -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
IFRAME_ORIGIN=https://wkylin.github.io
2 changes: 1 addition & 1 deletion src/pages/postmessage/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 2 additions & 0 deletions src/pages/postmessage/myIframe/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 4f458a7

Please sign in to comment.