Http 浏览器表示访问控制允许clojure环中不存在原始标头

Http 浏览器表示访问控制允许clojure环中不存在原始标头,http,clojure,cors,clojure-ring,Http,Clojure,Cors,Clojure Ring,我像这样通过客户端浏览器向服务器发出请求,但得到错误: Access to XMLHttpRequest at 'https://example.com/bar/' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. 但是,当使用clj-http.cl

我像这样通过客户端浏览器向服务器发出请求,但得到错误:

Access to XMLHttpRequest at 'https://example.com/bar/' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
但是,当使用clj-http.client时,我会得到以下标题:

{"Access-Control-Allow-Headers" "Content-Type",
  "Server" "Aleph/0.4.4",
  "Via" "1.1 vegur",
  "Content-Type" "application/edn",
  "Access-Control-Allow-Origin" "*",
  "Connection" "close",
  "Transfer-Encoding" "chunked",
  "Access-Control-Request-Method" "GET",
  "Date" "Sat, 14 Mar 2020 10:10:43 GMT",
  "Vary" "Accept-Encoding"},
如果通过clj-http.client请求在头中存在访问控制允许源,那么浏览器为什么会说它不存在

---编辑---

工作原理:

;; clj-http.client gives the correct response with the headers above. 
(get "https://www.example.com/bar")
给出:

{:cached nil,
 :request-time 456,
 :repeatable? false,
 :protocol-version {:name "HTTP", :major 1, :minor 1},
 :streaming? true,
 :http-client
 #object[org.apache.http.impl.client.InternalHttpClient 0x367237a0 "org.apache.http.impl.client.InternalHttpClient@367237a0"],
 :chunked? true,
 :reason-phrase "OK",
 :headers
 {"Access-Control-Allow-Headers" "Content-Type",
  "Server" "Aleph/0.4.4",
  "Via" "1.1 vegur",
  "Content-Type" "application/edn",
  "Access-Control-Allow-Origin" "*",
  "Connection" "close",
  "Transfer-Encoding" "chunked",
  "Access-Control-Request-Method" "GET",
  "Date" "Sat, 14 Mar 2020 18:54:05 GMT",
  "Vary" "Accept-Encoding"},
 :orig-content-encoding nil,
 :status 200,
 :length -1,
 :body
 "({:foo \"bar\", :foo2 \"bar2\", :foo4 0, :foo3 [\"...
 :trace-redirects []
}
什么不起作用

;; At the client, using cljs-http.client
   (go (let [response (<! (http/get https://example.com/bar))]  
        (prn response)))

响应的HTTP状态代码是什么?您可以使用浏览器devtools中的网络窗格进行检查。这是4xx还是5xx错误,而不是200 OK成功响应?状态如预期为200。我们需要完整的请求和响应。CORS是一个非常棘手的话题,尤其是对于Chrome。此外,如果您发出的请求不是“简单请求”-将发出需要正确处理的飞行前呼叫。此外,如果您发送凭据(如cookie或授权标头),则不能使用设置为“*”的“访问控制允许来源”。
{:status 0, :success false, :body "", :headers {}, :trace-redirects ["https://example.com/bar" "https://example.com/bar"], :error-code :http-error, :error-text " [0]"}