Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[30] Proxy Static Pages #317

Merged
merged 9 commits into from
Dec 17, 2024
Merged

[30] Proxy Static Pages #317

merged 9 commits into from
Dec 17, 2024

Conversation

danivovich
Copy link
Contributor

Map a proxy such that URLs attempt to load jekyll content from the static pages content.

Implements #30

Map a proxy such that URLs attempt to load jekyll content from the
static pages content.
@danivovich danivovich requested a review from stepchud December 10, 2024 15:30
@r-bartlett-gsa r-bartlett-gsa added this to the Sprint 12/17/24 milestone Dec 10, 2024
@r-bartlett-gsa r-bartlett-gsa linked an issue Dec 10, 2024 that may be closed by this pull request
2 tasks
app/controllers/pages_controller.rb Dismissed Show dismissed Hide dismissed
@danivovich danivovich changed the title Proxy Static Pages [30] Proxy Static Pages Dec 11, 2024
config/routes.rb Outdated Show resolved Hide resolved
@stepchud
Copy link
Contributor

one smaller issue is that the login and sign up button in the header go to the production login.gov site, so devs will need to log in to localhost via the /dashboard route (any 404 redirects there)

Copy link
Contributor

@stepchud stepchud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this is a dumb question or I don't understand how it works, but if the rails app is hosted on www.challenge.gov, and we reverse proxy to that same domain, won't it just create an infinite loop? are we migrating the jekyll server to a different domain?

app/controllers/pages_controller.rb Outdated Show resolved Hide resolved
@danivovich danivovich requested a review from stepchud December 13, 2024 20:28

RSpec.describe "PagesController" do
it "get new renders successfully" do
stub_request(:get, PagesController::HOST + PagesController::BASE_URL).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor

@stepchud stepchud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links to the active challenges on the homepage are broken. The URL path it is constructing is basically doubled up (see path= in the log output). Seems like the gsub for rewriting the links on the page isn't working on the BASE_URL gsub correctly because the links include that in the path still. Another issue is that it's not including the params in the request but I think the jekyll server needs the challenge param, e.g. ?challenge=eval-challenge-test, to fetch the correct challenge.
Screenshot 2024-12-13 at 2 01 34 PM

Here are some request logs where I put in some debug logging:

13:55:17 web.1   | Started GET "/preview/gsa/challenges-and-prizes/eval-dev/?challenge=eval-challenge-test" for ::1 at 2024-12-13 13:55:17 -0800
13:55:17 web.1   | Processing by PagesController#index as HTML
13:55:17 web.1   |   Parameters: {"challenge"=>"eval-challenge-test", "path"=>"preview/gsa/challenges-and-prizes/eval-dev"}
13:55:18 web.1   | path=/preview/gsa/challenges-and-prizes/eval-dev/preview/gsa/challenges-and-prizes/eval-dev/
13:55:18 web.1   | Redirected to http://localhost:3000/dashboard
13:55:18 web.1   | Completed 302 Found in 352ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.2ms)

@stepchud
Copy link
Contributor

The links to the active challenges on the homepage are broken. The URL path it is constructing is basically doubled up (see path= in the log output). Seems like the gsub for rewriting the links on the page isn't working on the BASE_URL gsub correctly because the links include that in the path still. Another issue is that it's not including the params in the request but I think the jekyll server needs the challenge param, e.g. ?challenge=eval-challenge-test, to fetch the correct challenge. Screenshot 2024-12-13 at 2 01 34 PM

Here are some request logs where I put in some debug logging:

13:55:17 web.1   | Started GET "/preview/gsa/challenges-and-prizes/eval-dev/?challenge=eval-challenge-test" for ::1 at 2024-12-13 13:55:17 -0800
13:55:17 web.1   | Processing by PagesController#index as HTML
13:55:17 web.1   |   Parameters: {"challenge"=>"eval-challenge-test", "path"=>"preview/gsa/challenges-and-prizes/eval-dev"}
13:55:18 web.1   | path=/preview/gsa/challenges-and-prizes/eval-dev/preview/gsa/challenges-and-prizes/eval-dev/
13:55:18 web.1   | Redirected to http://localhost:3000/dashboard
13:55:18 web.1   | Completed 302 Found in 352ms (ActiveRecord: 0.0ms (0 queries, 0 cached) | GC: 0.2ms)

FYI, this URL is working locally: http://localhost:3000/?challenge=eval-challenge-test

@stepchud
Copy link
Contributor

stepchud commented Dec 14, 2024

oh it's because the react app is loading those from the data API after the initial page load 🫤

Copy link
Contributor

@stepchud stepchud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@stepchud stepchud merged commit e1ce5be into dev Dec 17, 2024
11 checks passed
@stepchud stepchud deleted the 30-proxy-static-pages branch December 17, 2024 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proxy Challenge.gov Pages through Rails app
3 participants