Skip to content

Commit

Permalink
tweak the BASE_URL for react link rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
stepchud committed Dec 16, 2024
1 parent 19152f8 commit e518c5b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/controllers/pages_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class PagesController < ApplicationController
# and these constants will need to be updated. The will be similar to the commented out versions
DOMAIN = "federalist-2c628203-05c2-48ab-8f87-3eda79380559.sites.pages.cloud.gov"
HOST = "https://federalist-2c628203-05c2-48ab-8f87-3eda79380559.sites.pages.cloud.gov"
BASE_URL = "/preview/gsa/challenges-and-prizes/eval-dev/"
BASE_URL = "/preview/gsa/challenges-and-prizes/eval-dev"
# DOMAIN = "content.challenge.gov".freeze
# HOST = "https://content.challenge.gov".freeze
# BASE_URL = "/".freeze

def index
path = "#{BASE_URL}#{params[:path]}/"
path = "#{BASE_URL}/#{params[:path]}/"
reverse_proxy(HOST, path:, reset_accept_encoding: true, headers: { host: DOMAIN }) do |config|
config.on_missing do |_code, _response|
redirect_to "/dashboard"
Expand All @@ -31,17 +31,17 @@ def index

def assets
if params[:ext] == "min"
path = "#{HOST}#{BASE_URL}assets/#{params[:path]}.#{params[:ext]}.js"
path = "#{HOST}#{BASE_URL}/assets/#{params[:path]}.#{params[:ext]}.js"
response = Faraday.get(path)
send_data(response.body, type: 'application/javascript')
else
path = "#{BASE_URL}assets/#{params[:path]}.#{params[:ext]}"
path = "#{BASE_URL}/assets/#{params[:path]}.#{params[:ext]}"
reverse_proxy(HOST, path:, reset_accept_encoding: true, headers: { host: DOMAIN })
end
end

def root
path = BASE_URL
path = "#{BASE_URL}/"
reverse_proxy(HOST, path:, reset_accept_encoding: true, headers: { host: DOMAIN }) do |config|
config.on_response do |_code, response|
if response.body.present?
Expand All @@ -56,7 +56,7 @@ def root
def rewrite_links(html)
parsed_html = html.gsub(HOST, "/")
if BASE_URL.length > 1
parsed_html = parsed_html.gsub(BASE_URL, "/")
parsed_html = parsed_html.gsub(BASE_URL, "")
end
# rubocop:disable Rails/OutputSafety
parsed_html.html_safe
Expand Down

0 comments on commit e518c5b

Please sign in to comment.