diff --git a/Gemfile b/Gemfile index 7388a7a..25b0d57 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ # frozen_string_literal: true +ruby "3.3.5" + source "https://rubygems.org" gem "jwt", "~> 2.9" diff --git a/proxy_server.rb b/proxy_server.rb index c428a15..c7c2e6d 100644 --- a/proxy_server.rb +++ b/proxy_server.rb @@ -3,10 +3,13 @@ require "uri" require "json" require "jwt" -require "debug" -require "dotenv/load" require "openssl/pkey" +if ["development", "test"].include? ENV['RACK_ENV'] + require "dotenv/load" + require "debug" +end + class ProxyServer < Sinatra::Base set :port, 4567 # set :logging, true @@ -75,11 +78,15 @@ def forward_request(method) target_request.body = request.body.read end + # Override host + target_request["host"] = uri.hostname + # Log the headers for debugging purposes - puts "Forwarding headers to target request:" - target_request.each_header do |header, value| - puts "#{header}: #{value}" - end + # puts "Forwarding headers to target request:" + # target_request.each_header do |header, value| + # puts "#{header}: #{value}" + # end + # Execute the request to the target server Net::HTTP.start(uri.hostname, uri.port, use_ssl: uri.scheme == "https") do |http| response = http.request(target_request)