I know there seem to be some answers related to this topic, but none of them worked for me so far. I built a rails API backend with a front end built with React. The application was running fine but after I added some features and deployed again I started having issues with my CORS. The feature I added was related to Redis and Action cable. Now I am getting this error: Access to XMLHttpRequest at 'https://myestateapi.herokuapp.com/top_apartment' from origin 'https://frozen-bastion-98066.herokuapp.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
my setting have not changed I don't know why I am getting this.
In my config/application.rb
I have this
Rails.application.config.middleware.insert_before ActionDispatch::Static, Rack::Cors do
allow do
origins '*'
resource '*',
headers: :any,
methods: %i[get post put patch delete options head]
end
end
This very code worked fine. What could be causing this error? Or can anyone suggest a better gem than rack-cors
? I would be grateful to have help from anyone. Thank you in advance.