Question

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

Was it helpful?

Solution

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 /.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top