minha resposta é uma solução um pouco diferente.
acabamos criando nosso próprio "proxy" com base no ruby / sinatra, incluindo o tratamento de cookies.
get /(.*)/ do
if (asset? || download?) && !exception?
return redirect to(target_url), 301
end
begin
agent = Mechanize.new
cookies.each.map{ |k,v| agent.cookie_jar << Mechanize::Cookie.new(name: k, value: v, domain: ".we.us", path: "/") }
response = agent.get(target_url)
cookies.clear
agent.cookies.map{ |cookie| cookies[cookie.name] = cookie.value }
content_type(response.response['content-type'])
send("modify_#{target}", response.body)
rescue Mechanize::ResponseCodeError
p "throw a 404!"
status 404
end
end
def asset?
# binding.pry
extensions = %W(.jpg .png .gif .jpeg .ico .woff .ttf .gif .woff2 .cur)
url = target_url
url = url.split("?").first
url.downcase.end_with?(*extensions)
end
def target_url
target_host + query_string
end
def query_string
# binding.pry
#params['captures'].first
if env["PATH_INFO"] == "/"
"/"
else
env["REQUEST_URI"].scan(Regexp.new("#{env["PATH_INFO"]}.*")).first
end
end