day8 / re-frame-http-fx

A re-frame "effects handler" for performing Ajax tasks (via cljs-ajax)
MIT License
259 stars 27 forks source link

The 'Access-Control-Allow-Origin' header contains the invalid value '(null)' #15

Closed piotr-yuxuan closed 6 years ago

piotr-yuxuan commented 7 years ago

First, thanks for that piece of code. It's well designed and a very handy re-frame effectful effect :-)

However, I've just run into a behaviour I can't explain neither avoid when querying some URL. I've got a minimal (non-)working example to explain stuff rigorously and I describe it in the README.md.

https://github.com/piotr-yuxuan/mwe-cors-unexplained-behaviour

If the error lies on my side and not in your code's (as it's very likely to be) perhaps it would be worth adding a small explanation in your README.md: code needed to reproduce this behaviour is rather simple and I guess a lot of newbie (as I am) would stumble upon this pitfall.

danielcompton commented 7 years ago

HI @piotr-yuxuan re-frame-http-fx is a very thin wrapper over cljs-ajax. I took a quick look at our code and couldn't see anything obviously wrong here. I think what's happening is you need to provide an accepted content-type which is text/html. The GNU website is trying to do content negotiation, but your XHR request doesn't provide a content-type that it accepts. The CORS error is a bit of a red herring (I think), the real problem is the error page, which then blows up into a CORS error as the error page doesn't serve your CORS headers.

piotr-yuxuan commented 6 years ago

Closing because this was more a question than an actual issue.