1

I am getting this error while I am trying to hit on my api deployed on Heroku in rails application using Ruby on rails :

 Failed to load https://**: my API link deployed on Heroku No 
'Access-Control-Allow-Origin' header is present on the requested resource.
 Origin 'http://localhost:3000' is therefore not allowed access.
Logan
  • 101
  • 1
  • 2
  • 12
  • You have not provided much info but check this articles on how to handle ssl on heroku https://devcenter.heroku.com/articles/ssl-endpoint#provision-the-add-on && https://readysteadycode.com/howto-setup-ssl-with-rails-and-heroku – iamcaleberic Jan 28 '18 at 13:44

1 Answers1

2

http://localhost:3000 is not permitted via CORS. You need to set it up in your rails application deployed on heroku.

Add the below snippet to your config/application.rb file and then redeploy to heroku

  config.middleware.insert_before 0, Rack::Cors do
    allow do
      origins 'http://localhost:3000'
      resource '*', :headers => :any, :methods => [:get, :post, :options]
    end
  end
Adim
  • 1,716
  • 12
  • 13