title: Http request in clojurescript with re-frame
body: <p>I use Clojurescript + Reframe + http-fx.
  This is example src for http request:</p>
  <pre><code>(re-frame/reg-event-fx
   ::request-login 
   (fn [{:keys [db]} [_ req-data]]  
     {:db   (assoc db :loading true)
      :http-xhrio {:method          :post
                   :uri             &quot;http://localhost:8002/api/auth/login&quot;
                   :params          req-data
                   :timeout         8000      
                   :format          (ajax/json-request-format)
                   :response-format (ajax/json-response-format {:keywords? true})
                   :on-success      [::response-login-success]
                   :on-failure      [:bad-http-result]}}))
  </code></pre>
  <p>My dev shadow-cljs works on http://localhost:8280/</p>
  <p>But my api server on http://localhost:8002/ (this is other application).</p>
  <p>The library does not allow me to make requests to servers at other addresses.
  Only for (:uri &quot;http://localhost:8280/api/auth/login&quot;)</p>
  <p>In browser inspector displays: Provisional headers are shown! This is due to the referrer parameter in header, as I understand it.</p>
  <p>I tryed:</p>
  <pre><code> :uri     &quot;http://localhost:8002/api/auth/login&quot;
   :params  req-data
   :headers {&quot;referer&quot; &quot;http://localhost:8002/&quot; &quot;origin&quot; &quot;http://localhost:8002&quot;}
  </code></pre>
  <p>It does not help!
  I found information that it is necessary to do not an asynchronous request.</p>
  <p>I was able to run only this solution (call JS function from Clojurescript):</p>
  <pre><code>function myAjaxPost() {
      const xhttp = new XMLHttpRequest();
      xhttp.open(&quot;POST&quot;, &quot;http://localhost:8002/api/auth/login&quot;, false);
      xhttp.send(JSON.stringify({login:&quot;user1&quot;,password:&quot;pswd1&quot;}));
      console.log(xhttp.responseText);
  };
  
  </code></pre>
  <p>But How it is possible to set async mode for http-fx?</p>
  <p>It is possible to make requests for a different URLs?</p>