diff --git a/backend/Gemfile b/backend/Gemfile index 90b9edf..a486b04 100644 --- a/backend/Gemfile +++ b/backend/Gemfile @@ -6,10 +6,10 @@ ruby "3.3.4" gem "rails", "~> 7.1.3", ">= 7.1.3.4" # [1.1] APIs # JSON APIs -# gem "jbuilder" +gem "jbuilder" # Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin Ajax possible -# gem "rack-cors" +gem "rack-cors" # [2] Storage @@ -79,5 +79,6 @@ group :development do # gem "spring" # Errors gem "better_errors", "~> 2.10" + # Models + gem "annotate", "~> 3.2" end - diff --git a/backend/Gemfile.lock b/backend/Gemfile.lock index dc865c2..7f93977 100644 --- a/backend/Gemfile.lock +++ b/backend/Gemfile.lock @@ -75,6 +75,9 @@ GEM minitest (>= 5.1) mutex_m tzinfo (~> 2.0) + annotate (3.2.0) + activerecord (>= 3.2, < 8.0) + rake (>= 10.4, < 14.0) base64 (0.2.0) better_errors (2.10.1) erubi (>= 1.0.0) @@ -138,6 +141,9 @@ GEM irb (1.14.0) rdoc (>= 4.0.0) reline (>= 0.4.2) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) @@ -194,6 +200,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) @@ -289,6 +297,7 @@ PLATFORMS x86_64-linux DEPENDENCIES + annotate (~> 3.2) better_errors (~> 2.10) bootsnap database_cleaner (~> 2.0) @@ -298,9 +307,11 @@ DEPENDENCIES faker (~> 3.4) guard (~> 2.18) guard-rspec (~> 4.7) + jbuilder pg (~> 1.1) pry-rails (~> 0.3.11) puma (>= 5.0) + rack-cors rails (~> 7.1.3, >= 7.1.3.4) rspec-rails (~> 6.1) shoulda-matchers (~> 6.2) diff --git a/backend/config/initializers/cors.rb b/backend/config/initializers/cors.rb index 0c5dd99..e81c04c 100644 --- a/backend/config/initializers/cors.rb +++ b/backend/config/initializers/cors.rb @@ -5,12 +5,14 @@ # 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 "*" + # origins "http://vue:8080" + + resource "*", + headers: :any, + # credentials: true, + methods: [:get, :post, :put, :patch, :delete, :options, :head] + end +end