Reputation: 387
I have a sinatra app running on heroku.
My problem: I always get redirected to production environment (https://apps.facebook.com/myapp/) when I go to localhost (http://localhost:5000/). So I can't develop locally anymore.
I suspect that the custom google analytics I added has something to do with it, see below (source: . http://www.savio.no/blogg/a/104/how-to-track-facebook-iframes-with-google-analytics). It
<script type="text/javascript">
// This script is provided AS IS without warranty of any kind.
// See http://www.savio.no/blogg/a/104/ for more information.
// Smacked together by Eivind Savio May 2011
var FacebookURL = 'http://www.facebook.com/YourFacebookPage?sk=app_123456789';
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-XXXXXX-X']);
_gaq.push(['_addIgnoredRef', 'static.ak.facebook.com']);
// If Google Analytics is loaded and this page isn't framed inside our Facebook URL, frame the page.
if (_gaq.push && self.location == top.location) {
// Create a fake URL that we can filter in Google Analytics. This pageview also sends the traffic source data to Google Analytics.
_gaq.push(['_trackPageview','/facebook/campaign-tracking/']);
// Tracking done, let's frame the page
setTimeout(top.location.href = FacebookURL, 200);
} else if (self.location == top.location) {
// If Google Analytics doesn't load within 2 seconds, refresh and frame the page anyway. People dislike waiting. Change the time if you like.
setTimeout(top.location.href = FacebookURL, 2000);
} else {
// The Page is Framed. Let's track it.
_gaq.push(['_trackPageview']);
_gaq.push(['_trackPageLoadTime']);
}
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
So I removed it, but heroku still uses it, see below in the network console output, line 3. Whats going on here, is it a cache that doesnt get deleted? Any ideas?
[13:12:16.817] GET http://localhost:5000/ [HTTP/1.1 200 OK 395ms]
[13:12:17.330] GET https://apps.facebook.com/myapp/ [HTTP/1.1 200 OK 782ms]
[13:12:17.357] GET http://www.google-analytics.com/__utm.gif?xxxxxxxxxxxxxxxx [HTTP/1.1 200 OK 14ms]
[13:12:17.500] syntax error @ http://localhost:5000/:108
[13:12:18.326] POST https://xxxx.herokuapp.com/ [HTTP/1.1 302 Moved Temporarily 952ms]
[13:12:19.200] GET https://xxxx.herokuapp.com/ [HTTP/1.1 200 OK 734ms]
[13:12:19.827] GET https://xxxx.herokuapp.com/stylesheets/screen.css [HTTP/1.1 200 OK 262ms]
[13:12:19.829] GET https://xxxx.herokuapp.com/stylesheets/mobile.css [HTTP/1.1 200 OK 398ms]
[13:12:19.831] GET https://xxxx.herokuapp.com/javascripts/jquery-1.7.1.min.js [HTTP/1.1 200 OK 1032ms]
[13:12:20.093] GET https://xxxx.herokuapp.com/stylesheets/reset.css [HTTP/1.1 200 OK 135ms]
[13:12:20.096] GET https://xxxx.herokuapp.com/stylesheets/base.css [HTTP/1.1 200 OK 263ms]
[13:12:21.026] GET https://xxxx.herokuapp.com/images/house_suburb.jpg [HTTP/1.1 200 OK 308ms]
[13:12:21.051] GET https://xxxx.herokuapp.com/images/logo.png [HTTP/1.1 200 OK 295ms]
[13:12:21.109] GET https://www.facebook.com/dialog/oauth?api_key=xxxxxxxxxxxxxxxxcode&sdk=joey [HTTP/1.1 302 Found 192ms]
Upvotes: 0
Views: 470
Reputation: 9531
The problem stems from this:
} else if (self.location == top.location) {
// If Google Analytics doesn't load within 2 seconds, refresh and frame the page anyway. People dislike waiting. Change the time if you like.
setTimeout(top.location.href = FacebookURL, 2000);
}
Basically you're saying "if the page is not framed, redirect to the FacebookURL"
Upvotes: 1