0
0
Fork 0

Fix not being able to resolve public resources in development environment (#13505)

This commit is contained in:
Eugen Rochko 2020-04-25 22:01:08 +02:00 committed by GitHub
parent be637146f3
commit 2744f61696
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 3 deletions

View file

@ -25,7 +25,18 @@ class FetchResourceService < BaseService
end
def perform_request(&block)
Request.new(:get, @url).add_headers('Accept' => ACCEPT_HEADER).on_behalf_of(Account.representative).perform(&block)
Request.new(:get, @url).tap do |request|
request.add_headers('Accept' => ACCEPT_HEADER)
# In a real setting we want to sign all outgoing requests,
# in case the remote server has secure mode enabled and requires
# authentication on all resources. However, during development,
# sending request signatures with an inaccessible host is useless
# and prevents even public resources from being fetched, so
# don't do it
request.on_behalf_of(Account.representative) unless Rails.env.development?
end.perform(&block)
end
def process_response(response, terminal = false)