#getting security error Blocked a frame with origin from accessing a cross-origin frame

1 messages · Page 1 of 1 (latest)

queen pewter
#

hey folks I'm getting the cross-origin frame error please someone help me to solve it this is my code

export const InviteWindow = (props: NewWindowProps) => {
    const [container, setContainer] = useState<HTMLDivElement | null>(null);
    const newWindow = useRef<Window | null>(window);
    const router = useRouter()

    useEffect(() => {
        const div = document.createElement("div");
        setContainer(div);
    }, [])

    useEffect(() => {
      if(!newWindow){
        return;
      }
      
      const timer = setInterval(() => {
        if(!newWindow) {
            timer && clearInterval(timer);
            return;
        }

        const currentUrl = newWindow.current?.location.href;
        if(!currentUrl){
            return;
        }
        const searchParams = new URL(currentUrl).searchParams;
        const code = searchParams.get("code");
        if(code) {
            newWindow.current?.close()
        }
      }, 500)

      if(container){
        newWindow.current = window.open(`${props.url}`, "", "width=600,height=640,top=100,left=50");
        if(newWindow.current) {
            newWindow.current.document.body.appendChild(container);
            const curWindow = newWindow.current;
            curWindow.addEventListener('unload', () => props.onUnLoad())
        }
      }
    }, [newWindow, container])

    return container && createPortal(props.children, container);
}

I'm using NextJs

rose brook
#

The frame is not letting you embed it as it is in a different origin. If you own the frame then you can fix this, if not then you’re out of luck really, it’s a security policy enforced by the other site

queen pewter
rose brook
#

Doesn’t change the answer unfortunately. You can’t embed a frame if the owner doesn’t want you to

rose brook
#

What url are you using and what url is the frame loading?

rose brook
#

Looks like you’ll have to laugh the OAuth flow in a new window/tab and not embedded within a frame

queen pewter