superstructor / re-frame-fetch-fx

js/fetch Effect Handler for re-frame
MIT License
40 stars 8 forks source link

fetch not working with localhost. #1

Closed zendevil closed 4 years ago

zendevil commented 4 years ago

When I try the following in my re-frame :fetch map:

{:method :get 
:url "https://google.com"
:params some-params
:response-content-types {#"application/.*json" :json}
:on-success print-response
:on-failure show-failure
}

the on-success function is run on the "https://google.com" but the on-failure function is run when I try a localhost:3000/some-route route. I know that the route works because it works when directly put into the browser. The route is supposed to return a json.

superstructor commented 4 years ago

The issue your having is CORS blocks different origins by default. This is the same as the underlying js/fetch API. Please set appropriate :mode as per examples. I also added a unit test that passes for this case.