Skip to content

Commit

Permalink
setup CORS
Browse files Browse the repository at this point in the history
  • Loading branch information
fermion committed Jan 23, 2024
1 parent a811ad9 commit 39f5918
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ gem "sprockets-rails"
gem "pg", "~> 1.1"

gem "puma", ">= 5.0"
gem 'rack-cors'
gem "sidekiq", "~> 7.2"
gem "importmap-rails"
gem "turbo-rails"
Expand Down
3 changes: 3 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ GEM
nio4r (~> 2.0)
racc (1.7.3)
rack (3.0.8)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
Expand Down Expand Up @@ -333,6 +335,7 @@ DEPENDENCIES
passwordless (~> 1.1)
pg (~> 1.1)
puma (>= 5.0)
rack-cors
rails (= 7.1.2)
rspec-rails
selenium-webdriver
Expand Down
12 changes: 12 additions & 0 deletions config/initializers/cors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins "http://localhost:8080"
"https://staffplan-ui.fermion.dev"

resource "*",
headers: :any,
methods: [:get, :post, :put, :patch, :delete, :options, :head],
credentials: true,
max_age: 86400
end
end

0 comments on commit 39f5918

Please sign in to comment.