Rails 8 docker を使用している場合に rspec > requests spec で 403 エラーが発生した場合の確認点について
- POST
Rails 8 docker を使用している場合に rspec > requests spec で 403 エラーが発生した場合の確認点について調査したものを備忘録として残しておく
環境 ruby: 3.4.2 rails: 8.0.2 mode: API mode エラー内容 Rails 6 以降で追加された DNS リバインディングに関するエラーが発生している
※エラー内容と根本原因は異なるため注意
状況としては以下の通り
Rails Server 起動しての実行は成功 docker-compose exec app bash bin/rails s -b 0.0.0.0 RSpec > Request 実行時に 403 エラーが発生 Request Spec 以外は成功 docker-compose exec app bash bin/rspec spec/requests/xxxx_spec.rb 下記の html が返却される <!-- 一部抜粋 --> <main role="main" id="container"> <h2>To allow requests to these hosts, make sure they are valid hostnames (containing only numbers, letters, dashes and dots), then add the following to your environment configuration:</h2> <pre> config.