Skip to content

Commit

Permalink
Merge pull request #83 from Progaku-copy/feature/#10cors-setup
Browse files Browse the repository at this point in the history
CORSの設定を実施
  • Loading branch information
kuri0616 authored Sep 1, 2024
2 parents 9c7e078 + 3234f3e commit 81f3eb7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
7 changes: 6 additions & 1 deletion backend/.rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,9 @@ Style/HashSyntax:
Enabled: false

RSpec/ExampleLength:
Enabled: false
Enabled: false

# SymbolArrayのStyleを%記法に統一
Style/SymbolArray:
EnforcedStyle: percent
MinSize: 2
18 changes: 9 additions & 9 deletions backend/config/initializers/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 ENV.fetch('FRONTEND_DOMAIN')

resource "*",
headers: :any,
methods: %i[get post put patch delete options head]
end
end
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ services:
env_file:
- ./infra/env/backend.env
ports:
- 3000:3000
command: sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 3000 -b '0.0.0.0'"
- 8080:8080
command: sh -c "rm -f tmp/pids/server.pid && bundle exec rails s -p 8080 -b '0.0.0.0'"
depends_on:
db:
condition: service_healthy
Expand Down
1 change: 1 addition & 0 deletions infra/env/backend.env.template
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
DATABASE_URL=mysql2://root:root@db/app_development
DATABASE_TEST_URL=mysql2://root:root@db/app_test
FRONTEND_DOMAIN=http://localhost:3000

0 comments on commit 81f3eb7

Please sign in to comment.