리디렉션 후 새탭 닫기

00_8_3·2022년 7월 12일
0

리디렉션

Client -> Server -> 3rd Party

써드파티의 response로 리디렉션이 있는데
새 탭이 팝업되는 것을 막기

참고

window.close의 경우
보안상의 이유로 window.open으로 열린 창만 닫을 수 있다.

This method can only be called on windows that were opened by a script using the Window.open() method. If the window was not opened by a script, an error similar to this one appears in the console: Scripts may not close windows that were not opened by script.

해결


...//리디렉션 되는 라우터라 가정
app.get("/redirect", () =>{

	ctx.body = "<script>window.close();</script>"; // koa
  	//res.send("<script>window.close();</script>"); // express
})

출처

https://developer.mozilla.org/en-US/docs/Web/API/Window/close

0개의 댓글