Skip to content

Commit

Permalink
Merge pull request #2131 from cul-it/DACCESS-314
Browse files Browse the repository at this point in the history
DACCESS-314 - CORS support for status page
  • Loading branch information
jgreidy authored Jun 3, 2024
2 parents 3e166bf + da45b2b commit 95d3d61
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions blacklight-cornell/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,4 @@ gem 'uri', '0.12.2'
# gem 'pkg-config', '1.5.4'
gem 'status-page'
gem 'concurrent-ruby', '1.2.3', require: 'concurrent'
gem "rack-cors", require: "rack/cors"
3 changes: 3 additions & 0 deletions blacklight-cornell/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,8 @@ GEM
rack (2.2.9)
rack-contrib (2.4.0)
rack (< 4)
rack-cors (2.0.2)
rack (>= 2.0.0)
rack-protection (3.2.0)
base64 (>= 0.1.0)
rack (~> 2.2, >= 2.2.4)
Expand Down Expand Up @@ -928,6 +930,7 @@ DEPENDENCIES
pry
pry-byebug
puma (~> 6.4, >= 6.4.2)
rack-cors
rails (~> 6.1.7)
rb-inotify
rb-readline (~> 0.5.x)
Expand Down
5 changes: 5 additions & 0 deletions blacklight-cornell/app/controllers/status_page.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class StatusController < ApplicationController
def index
render html: StatusPage.check.html
end
end
8 changes: 8 additions & 0 deletions blacklight-cornell/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ class Application < Rails::Application

# Search results limit, to prevent deep paging issues
config.search_limit = 20000

config.middleware.insert_before 0, Rack::Cors do
allow do
origins "https://amplify-pages.d9ohqorlfrbif.amplifyapp.com", "*.library.cornell.edu"
resource "/status", headers: :any, methods: [:get]
resource '/status.json', headers: :any, methods: [:get]
end
end
end
end
if true
Expand Down
8 changes: 8 additions & 0 deletions blacklight-cornell/config/initializers/cors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "*.library.cornell.edu" # adjust this if you want to limit origins
resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head]
end
end
2 changes: 2 additions & 0 deletions blacklight-cornell/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,6 @@
# put 'aeon/scan_aeon/:id' => 'aeon#scan_aeon', :as => 'scan_paeon', :constraints => { :id => /.+/}
mount BlacklightCornellRequests::Engine => '/request', :as => 'blacklight_cornell_request'
mount MyAccount::Engine => '/myaccount', :as => 'my_account'

get "/status", to: "status#index"
end

0 comments on commit 95d3d61

Please sign in to comment.