Check if url can load in iframe

Snip.ly perfectly checks if the entered web address can be used in an iframe. I would like to reproduce it in ruby. Looking through their code, they send an ajax request to their server, and this is where they do the verification.

Even after the extensive search engine was unable to find anything that could help me with this.

My use case is that we allow users to add news lists to their page that appear in the iframe, and would like to show this if the entered url can be used in the iframe.

+4
source share
1 answer

, X-Frame-Options. , , .

, . , iframe.

. , your-server.com, user.com/list. :

, : - - URL-; css/ - ajax

, html 4. https://github.com/waterlink/rack-reverse-proxy 2 3 .

, config/application.rb:

config.middleware.insert(0, Rack::ReverseProxy) do  
  reverse_proxy_options timeout: 10 # avoids waiting for pages that take forever to load
  reverse_proxy(/proxy\?url=(.*)/, '$1') # reverse proxy on the url parameter
end
0

Source: https://habr.com/ru/post/1679398/


All Articles