First go to your Gemfile and uncomment gem 'rack-cors'. Then run bundle install
After that go to config/initializers folder. There, you should find a file called cors.rb.
Uncomment the code that looks like this
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
change the line that says origins 'example.com' to origin '*' or if you're request will be originating from a particular origin, then set it accordingly.
This worked for me. Hope it works for you as well. Cheers
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
If you are using Rails 6:
First go to your
Gemfile
and uncommentgem 'rack-cors'
. Then runbundle install
After that go to
config/initializers
folder. There, you should find a file calledcors.rb
.Uncomment the code that looks like this
change the line that says
origins 'example.com'
toorigin '*'
or if you're request will be originating from a particular origin, then set it accordingly.This worked for me. Hope it works for you as well. Cheers