Skip to content

Commit

Permalink
openminted-service: Fix not absolute URIs
Browse files Browse the repository at this point in the history
  • Loading branch information
mimame committed Jul 13, 2018
1 parent 46b72ba commit 8f2cf68
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions openminted-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ deployment_mode: local
local:
request_headers: "Host"
reverse_proxy: ""
protocol: "http"
server:
request_headers: "X-Forwarded-Host"
reverse_proxy: "service/openminted"
protocol: "http"
5 changes: 3 additions & 2 deletions src/openminted-service.cr
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ module Openminted::Service
request_headers = deployment_yml[deployment_mode]["request_headers"].to_s
reverse_proxy = deployment_yml[deployment_mode]["reverse_proxy"].to_s
reverse_proxy = "/#{reverse_proxy}/" unless reverse_proxy.empty?
request_protocol = deployment_yml[deployment_mode]["protocol"].to_s

# cas_has use uuid as key and a hash as value with the file uploaded (written as UUID_ + filename) and its status
alias Cas_Entry = Hash(Symbol, String | Status)
Expand Down Expand Up @@ -110,7 +111,7 @@ module Openminted::Service

env.response.content_type = "application/json"
uri = uri.lchop("/") unless reverse_proxy.empty?
{:url => "#{host}#{reverse_proxy}#{uri}/#{uuid}", :status => status.to_s}.to_json
{:url => "#{request_protocol}://#{host}#{reverse_proxy}#{uri}/#{uuid}", :status => status.to_s}.to_json
end
end

Expand Down Expand Up @@ -151,7 +152,7 @@ module Openminted::Service

reverse_proxy = "/" if reverse_proxy.empty?
URL_PATHS.each do |k, v|
response[k] = "#{host}#{reverse_proxy}#{v}/#{process_id}"
response[k] = "#{request_protocol}://#{host}#{reverse_proxy}#{v}/#{process_id}"
end
response["status"] = cas_entry[:status].to_s
end
Expand Down

0 comments on commit 8f2cf68

Please sign in to comment.