History

Route external redirections through a different origin

Thibaut committed 11 years ago

Commit ac2cbdd1 parent e1ec0f56 files · +20 −11Browse files

Showing the changes to lib (1 of 6 files). Show all

Unified · Split

lib/app.rb+9−0
@@ -172,6 +172,15 @@ class App < Sinatra::Application · 171 unmodified lines
172 halt erb :unsupported if unsupported_browser?172 halt erb :unsupported if unsupported_browser?
173 end173 end
174 174
175 OUT_HOST = 'out.devdocs.io'.freeze
176
177 before do
178 if request.host == OUT_HOST && !request.path.start_with?('/s/')
179 query_string = "?#{request.query_string}" unless request.query_string.empty?
180 redirect "http://devdocs.io#{request.path}#{query_string}", 302
181 end
182 end
183
175 get '/manifest.appcache' do184 get '/manifest.appcache' do
176 content_type 'text/cache-manifest'185 content_type 'text/cache-manifest'
177 expires 0, :'no-cache'186 expires 0, :'no-cache'