Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can a server check whether a request is coming from an iframe (Node.js)?

  1. I want my server to be able to check whether a request that came through came from within an iframe

  2. If the request came from within an iframe, I want my server to be able to find the domain name of the parent of that iframe

Is any of the above possible and if yes how can I implement such a check in a Node.js/Express.js server?

Thank you in advance for any help

like image 370
Sprout Coder Avatar asked Oct 30 '22 15:10

Sprout Coder


1 Answers

Just check the parent's url here:

request.headers.referer

If there is no iFrame, it will be undefined.

like image 179
Max Hesari Avatar answered Nov 12 '22 22:11

Max Hesari