2

My site is using reactjs as a front end and using Ruby on Rails 5 api only app as a back end (store on the different host)

So my front end is running on https://xxxx.com and sent the request to https://api.xxxx.com to get the data from the service.

But when i open my site on Google Chrome i got this response

Fetch API cannot load https://api.xxxx.com/v1/books?top_rate=true. Redirect failed.
Uncaught (in promise) TypeError: Failed to fetch

But some of the request is fine with the correct data even this.

Request URL:https://api.xxxx.com/v1/books?in_theater=true
Request Method:GET
Status Code:304 Not Modified

Then i tried open it on Firefox and Safari they work fine not like Google chrome.

this is my application.rb file

config.middleware.insert_before 0, Rack::Cors do
      allow do
        origins '*'
        resource '*', :headers => :any, :methods => [:get, :post, :patch, :delete, :options, :put]
      end
    end

So how can i make it works on google chrome?

Thanks!

Varis Darasirikul
  • 2,591
  • 6
  • 25
  • 58

0 Answers0