diff --git a/app/controllers/api/v0/health_checks_controller.rb b/app/controllers/api/v0/health_checks_controller.rb index 2b5b72a06..d3bb6c36a 100644 --- a/app/controllers/api/v0/health_checks_controller.rb +++ b/app/controllers/api/v0/health_checks_controller.rb @@ -34,6 +34,8 @@ module Api private def authenticate_with_token + return if request.local? + key = request.headers["health-check-token"] return if key == SiteConfig.health_check_token diff --git a/spec/requests/api/v0/health_checks_spec.rb b/spec/requests/api/v0/health_checks_spec.rb index 7b83c7924..bfe2ccf3b 100644 --- a/spec/requests/api/v0/health_checks_spec.rb +++ b/spec/requests/api/v0/health_checks_spec.rb @@ -8,6 +8,7 @@ RSpec.describe "HealthCheck", type: :request do context "without a token" do it "returns an unauthorized request" do + allow_any_instance_of(ActionDispatch::Request).to receive(:remote_addr).and_return("0.0.0.0") # rubocop:disable RSpec/AnyInstance get app_api_health_checks_path expect(response.status).to eq(401) end