getting security error in NextJs

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);
}
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
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server