From ffcbc27fc2496ce630a450cad788d06b53243c6e Mon Sep 17 00:00:00 2001 From: Garrett Bowman Date: Thu, 12 Sep 2024 15:46:36 -0500 Subject: [PATCH] Feat: CORS Setup --- Gemfile | 1 + Gemfile.lock | 3 +++ config/initializers/cors.rb | 18 +++++++++--------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 4dd0317..7fdcb79 100644 --- a/Gemfile +++ b/Gemfile @@ -61,3 +61,4 @@ group :development do # gem "spring" end +gem 'rack-cors' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index fd03982..c8659de 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -177,6 +177,8 @@ GEM nio4r (~> 2.0) racc (1.8.1) rack (3.1.7) + rack-cors (2.0.2) + rack (>= 2.0.0) rack-session (2.0.0) rack (>= 3.0.0) rack-test (2.1.0) @@ -301,6 +303,7 @@ DEPENDENCIES pg (~> 1.1) pry puma (>= 5.0) + rack-cors rails (~> 7.1.3, >= 7.1.3.4) rspec rspec-rails (~> 5.0.0) diff --git a/config/initializers/cors.rb b/config/initializers/cors.rb index 0c5dd99..be70102 100644 --- a/config/initializers/cors.rb +++ b/config/initializers/cors.rb @@ -5,12 +5,12 @@ # Read more: https://github.com/cyu/rack-cors -# Rails.application.config.middleware.insert_before 0, Rack::Cors do -# allow do -# origins "example.com" -# -# resource "*", -# headers: :any, -# methods: [:get, :post, :put, :patch, :delete, :options, :head] -# end -# end +Rails.application.config.middleware.insert_before 0, Rack::Cors do + allow do + origins '*' + + resource '*', + headers: :any, + methods: [:get, :post, :put, :patch, :delete, :options, :head] + end +end