Skip to content

Commit

Permalink
feat: Add CORS (#10)
Browse files Browse the repository at this point in the history
* chore: Add rack-cors

* chore: Add initializers/cors.rb
  • Loading branch information
ramos-ph authored Nov 1, 2023
1 parent 58439a0 commit c3f4724
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ gem "bootsnap", require: false
# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

gem "rack-cors"

group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
Expand Down
3 changes: 3 additions & 0 deletions backend/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ GEM
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.8)
rack-cors (2.0.1)
rack (>= 2.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rails (7.0.8)
Expand Down Expand Up @@ -195,6 +197,7 @@ DEPENDENCIES
bootsnap
debug
puma (~> 5.0)
rack-cors
rails (~> 7.0.8)
rspec-rails (~> 6.0.3)
shoulda-matchers (~> 5.0)
Expand Down
6 changes: 6 additions & 0 deletions backend/config/initializers/cors.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Rails.application.config.middleware.insert_before 0, Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [:get, :post, :patch, :put, :delete]
end
end

0 comments on commit c3f4724

Please sign in to comment.