I have a Rails API and I have Rack::Cors
setup in my application.rb
to prevent requests from any origin other than https://my-website.com
as:
config.middleware.insert_before 0, Rack::Cors do
allow do
origins 'https://my-website.com'
resource '*',
headers: %w[Authorization],
methods: %i[get post put delete options head],
expose: %w[Authorization]
end
end
Additionally I allow websocket connections as:
config.action_cable.url = %r{/wss:\/\/*/}
config.action_cable.allowed_request_origins = 'https://my-website.com'
And lastly I have a status
checker for my Application Load Balancer
and for that I allow http requests to /status
as:
config.force_ssl = true
config.ssl_options = {
hsts: { subdomains: true },
redirect: { exclude: ->(request) { request.path =~ /status/ } }
}
So as you can see every path except /status
should be https
only but I am still getting errors such as below in my production error tracker:
#590 ActionController::RoutingError: No route matches [OPTIONS] "/"
In the details I get the source as:
How is it possible for someone to manage to reach my actual route when the origin is not added in my CORS configuration
?