Blocked frame with source "https://www.facebook.com" from access to frame with source "http://myapp.herokuapp.com"

I get an unlimited amount of this message (e.g. in a loop) and it crashes the website

Rails 4.0.0 (with Turbolinks)

Error message

Blocked frame with source " https://www.facebook.com " from access frame with source " http://app.herokuapp.com ". Request frame access has the protocol "https", access to the frame has the protocol "http". Protocols must comply.

Facebook.js.coffee

fb_root = null fb_events_bound = false $ -> loadFacebookSDK() bindFacebookEvents() unless fb_events_bound bindFacebookEvents = -> $(document) .on('page:fetch', saveFacebookRoot) .on('page:change', restoreFacebookRoot) .on('page:load', -> FB?.XFBML.parse() ) fb_events_bound = true saveFacebookRoot = -> fb_root = $('#fb-root').detach() restoreFacebookRoot = -> if $('#fb-root').length > 0 $('#fb-root').replaceWith fb_root else $('body').append fb_root loadFacebookSDK = -> window.fbAsyncInit = initializeFacebookSDK $.getScript("//connect.facebook.net/it_IT/all.js") initializeFacebookSDK = -> FB.init channelUrl : 'http://app.heroku.com/page/fbchannel' appId : 'MY_ID_HERE' status : true cookie : true xfbml : true 

PageController

 class PageController < ApplicationController skip_before_action :authenticate_user! def fbchannel cache_expire = 1.year response.headers["Pragma"] = "public" response.headers["Cache-Control"] = "max-age=#{cache_expire.to_i}" response.headers["Expires"] = (Time.now + cache_expire).strftime("%d %m %Y %H:%I:%S %Z") render :layout => false, :inline => "<script src='//connect.facebook.net/it_IT/all.js'></script>" end end 

FBlike (assistant)

 def fblike(resource, layout = 'standard') content_tag(:div, "", class:"fb-like", data: { href: polymorphic_url(resource), width: "225", show_faces: false, stream: false, show_border: false, header: false, layout: layout } ) end 
+4
source share
1 answer

Pretty old question, but still open. So if you have not already seen this answer, Mademoiselle Geek is in place. A quick double check of my heroku application confirms that in fact you can just type https: instead of http: and it will automatically accept an SSL connection - no configuration required. The only thing you need to do is set up in your Facebook.js.coffee-this section.

 initializeFacebookSDK = -> FB.init channelUrl : 'http://app.heroku.com/page/fbchannel' 

Change to..

 initializeFacebookSDK = -> FB.init channelUrl : 'https://app.heroku.com/page/fbchannel' 

Then, depending on your operating system (I use linux), do a quick grep search (or find the text of the files in the directory) for http://app.heroku and change it to https to be safe.

0
source

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


All Articles