Skip to content

Why would the cljs-http.client request be blocked by the cors policy if the clj-http.client request isn't? #127

@zendevil

Description

@zendevil

I make a request like so using clj-http.client

(http/get "https://www.example.com/bar")

and get a response with status 200.

However, when I make the same request with cljs-http.client like so:

(go (let [response (<! (http/get (str "https://www.example.com" "/bar")))]
         (prn response)))

I get a response with status 0, and in the browser it says that it's been blocked by the cors policy.

Why would the cljs-http.client request be blocked by the cors policy if the clj-http.client request isn't? I have manually set the headers in ring like so:

(defn response [data & [status]]
  {:status (or status 200)
   :headers {"Content-Type" "application/edn"
             "Access-Control-Allow-Headers" "Content-Type"
             "Access-Control-Allow-Origin" "*"
             "Access-Control-Request-Method" "GET"}
   :body (pr-str data)})

I wrap my response for route "bar" with the function response above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions