Facebook Sinatra app doing strange redirects - facebook

We have a Facebook application implemented as tabs in a page. However, for certain users, it does weird redirects. This doesn't happen for everyone though, which is why I can't wrap my head around it.
When I go in Chrome incognito mode to our page without being logged in, it seems to happen to me too. What happens exactly?
The multiple tabs on the left of the page are our application tabs. However, something seems to go wrong when clicking on them. I always get the same frontpage, which is the 'Socialabs' page. My heroku logs indicate this:
2012-02-17T14:29:09+00:00 app[web.1]: 193.191.150.2 - - [17/Feb/2012 14:29:09] "POST /small HTTP/1.1" 302 - 0.0025
2012-02-17T14:29:09+00:00 heroku[router]: POST socialapp.herokuapp.com/small dyno=web.1 queue=0 wait=0ms service=28ms status=302 bytes=0
2012-02-17T14:29:09+00:00 app[web.1]: 193.191.150.2 - - [17/Feb/2012 14:29:09] "GET / HTTP/1.1" 302 - 0.0009
2012-02-17T14:29:09+00:00 heroku[router]: GET socialapp.herokuapp.com/ dyno=web.1 queue=0 wait=0ms service=10ms status=302 bytes=0
2012-02-17T14:29:09+00:00 app[web.1]: 193.191.150.2 - - [17/Feb/2012 14:29:09] "GET /tab HTTP/1.1" 200 2173 0.0112
2012-02-17T14:29:09+00:00 heroku[router]: GET socialapp.herokuapp.com/tab dyno=web.1 queue=0 wait=0ms service=14ms status=200 bytes=2173
What seems to happen when a user visits, in this case, the 'Small' tab is as follows:
a POST happens to the /small route of our application. This is to be expected. However, instead of rendering our erb template for that route, we get another redirect: /. This route redirects to /tab, as specified in our routes.
I can't figure out why /small redirects to /. The route looks like this in our sinatra application:
get "/contact" do
erb :contact
end
post "/contact" do
#on fb post we redirect to get route and display view
redirect '/contact'
end
I really can't figure this out. The complete contents of my app.rb file can be found in this gist: https://gist.github.com/1864561
Thanks in advance

From your app.rb you have:
before do
# HTTPS redirect
if settings.environment == :production && request.scheme != 'https'
redirect "https://#{request.env['HTTP_HOST']}"
end
end
I don't know the Facebook api or how their apps work, but it looks like it could be this filter that's redirecting any none https request to /.

Related

Signup/login page working in localhost, but on Heroku I get an Application error (h12/ 503)

I'm able to signup as a user and login as a user successfully on my local host, but on Heroku I receive an application error. It looks like the request is a timeout issue (H12 / 503 error). I'm confused because the login and signup was working fine about a month ago. I took a break from the project and at the time Heroku was deployed successfully and was working. Now I'm having problems on Heroku and don't know how I can fix the issue or what caused it in the first place.
This is my heroku log -
2021-04-13T03:30:27.742004+00:00 heroku[router]: at=error code=H12 desc="Request timeout" method=POST path="/auth/signup" host=reciperec-cristina.herokuapp.com request_id=e0e634e0-fd8e-4517-b428-f319e6beaddb fwd="73.202.97.117" dyno=web.1 connect=1ms service=30000ms status=503 bytes=0 protocol=https

Issues converting database from sqlite to postgres

Recently deployed a new webapp to Heroku. The app was prototyped using SQLite and am having difficulty with the database implementation in Heroku which uses postgresql. Namely, I am receiving this error and I am not sure how to troubleshoot:
2020-05-10T13:22:15.250905+00:00 app[web.1]: HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
2020-05-10T13:22:15.250906+00:00 app[web.1]:
2020-05-10T13:22:15.250906+00:00 app[web.1]: [SQL: SELECT count(*) AS count_1
2020-05-10T13:22:15.250907+00:00 app[web.1]: FROM (SELECT favorites.fav_id AS favorites_fav_id, favorites.user_id AS favorites_user_id, favorites.post_id AS favorites_post_id, favorites.fav_date AS favorites_fav_date
2020-05-10T13:22:15.250907+00:00 app[web.1]: FROM favorites
2020-05-10T13:22:15.250907+00:00 app[web.1]: WHERE favorites.post_id = %(post_id_1)s) AS anon_1]
2020-05-10T13:22:15.250908+00:00 app[web.1]: [parameters: {'post_id_1': 1}]
2020-05-10T13:22:15.250908+00:00 app[web.1]: (Background on this error at: http://sqlalche.me/e/f405)
2020-05-10T13:22:15.255615+00:00 app[web.1]: 10.31.64.150 - - [10/May/2020:13:22:15 +0000] "GET /home HTTP/1.1" 500 290 "https://benchofthoughts.herokuapp.com/post/new" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36"
2020-05-10T13:22:15.254572+00:00 heroku[router]: at=info method=GET path="/home" host=benchofthoughts.herokuapp.com request_id=1eed4376-3745-471d-8623-70217574197a fwd="47.20.85.233" dyno=web.1 connect=1ms service=31ms status=500 bytes=767 protocol=https
From reading this question and this question it looks like the query is trying to use a string instead of an int as the key to pull the relevant data, but this seemed to work fine using the prototype database. I am using SQLAlchemy for the queries so I assume the right variable types are implicitly being used, but I am not sure.
Can someone point me in the right direction to address this error?

Serving two (ipython generated) reveal slide shows at once

I'd like to be able to have two sets of slides, produced from two different notebooks, open at once in my browser. This use case is not supported, as far as I can tell, by the option --post serve of ipython nbconvert --to slides (of course, I'd be happy to be disproved).
My tactic has been to start a local server, as in
python -m SimpleHTTPServer 8001
and open the slide shows like this
google-chrome http://127.0.0.1:8001/my.slides.html
but now I get a bunch of messages alike
127.0.0.1 - - [31/Mar/2015 12:03:49] code 404, message File not found
127.0.0.1 - - [31/Mar/2015 12:03:49] "GET /reveal.js/css/reveal.css HTTP/1.1" 404 -
whose meaning is quite clear to me... so I did
ln -s /path/to/local/copy/of/reveal.js/ .
google-chrome http://127.0.0.1:8001/`
but now I have
127.0.0.1 - - [31/Mar/2015 12:07:29] code 404, message File not found
127.0.0.1 - - [31/Mar/2015 12:07:29] "GET /custom.css HTTP/1.1" 404 -
examining the source of my.slides.html I see the lines
<!-- Custom stylesheet, it must be in the same directory as the html file -->
<link rel="stylesheet" href="custom.css">
so I'm bound to the conclusion that --post serve does an awful lot of things at my back and that I'm out of luck in my attempt to save a standalone slide-show and have it served by a local HTTP server.
How can I have a properly served slide show without resorting to --post serve?

Facebook Canvas Application Does Not Load <body>

My question is almost identical to the one found here: Facebook canvas application never loads <body> contents?
However I'm running flask through Heroku's cedar stack. My url has always been the heroku subdomain so the solution above does not apply. Most of the time the application never loads past the head tags. Has anyone made any progress on this problem?
What I've found is that the post to Heroku is not asking for all the required bytes. Here is what my POST looks like from Heroku logs:
2012-07-06T02:33:33+00:00 app[web.1]: 10.191.221.194 - - [06/Jul/2012 02:33:33] "POST /?fb_source=search&ref=ts HTTP/1.1" 200 -
2012-07-06T02:33:33+00:00 heroku[router]: POST simple-frost-5348.herokuapp.com/?fb_source=search&ref=ts dyno=web.1 queue=0 wait=0ms service=3040ms status=200 bytes=2757
You'll see it is asking for 2757 bytes, which is exactly where the truncation occurs in my app.
It happens only after you log in and connect with the FB app. Hope this helps.

QuickTime Plugin not sending cookies

The application has a page with thumbnails. Clicking on a thumbnail calls the SetURL() javascript function on the player object.
In Safari on Windows, about 75% of the time, the plugin makes the request, sends the cookie, and life is good. The other 25% of the time, it fails to load at all half the time and when it does load, it won't loop. When it fails, we see the following requests:
127.0.0.1 - [20/May/2009:11:15:19 -0400] "GET /full/?id=1 HTTP/1.1" 302 - "-" 80 7542 0 QuickTime/7.6 (qtver=7.6;os=Windows NT 5.1Service Pack 3)
127.0.0.1 - [20/May/2009:11:15:19 -0400] "GET /denied/ HTTP/1.1" 200 3385 "-" 80 9050 0 QuickTime/7.6 (qtver=7.6;os=Windows NT 5.1Service Pack 3)
127.0.0.1 - [20/May/2009:11:15:20 -0400] "GET /full/?id=1 HTTP/1.1" 200 2639638 "-" 80 2005787 2 Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1
The first request comes directly from the plugin and the request does not contain the session cookie, so the app redirects it to the "unauthorized access" page. We then see the plugin make the request to the redirected page. Then we see the same initial request from the browser itself. That request contains the cookie so it succeeds. About half the time, the movie plays, the other half it doesn't.
As I said, if we have 10 thumbnails on a page, everything works fine for at least 7 of them so we know the plugin is actually loaded. There are no javascript errors.
I have seen similar behavior in IE, but have not been able to reproduce it consistantly.
Thoughts?
On our development servers we password protect the sites at the server level (via htpasswd).
In Firefox, the first time the SetURL() was called for a new movie, the browser would wait and pop the password alert, regardless of whether or not it was "remembered" in the keychain. Once the credentials were sent, then QuickTime would load the movie.
In Chrome, it was remembered.
IE still won't swap the file. Downloading Charles Proxy now...