Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CORSの設定を実施 #83

Merged
merged 7 commits into from
Sep 1, 2024
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
Loading