Fork me on GitHub
#yada
<
2018-05-04
>
bradford19:05:25

Hi! I'm having CORS problems. I think I'm doing it correctly? The browser says

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at . (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).
and I'm accessing from http://localhost:9000

bradford19:05:49

(def campaign-item-resource
  (yada/resource
   {:parameters {:path {:client_id String
                        :user_id String
                        :campaign_id String}}
    :produces   ["application/json"]
    :access-control {:allow-origin ["" "" "" ""
                                    "" ""]
                     :allow-credentials true :allow-headers ["authorization" "accept" "accept-language" "connection" "content-type" "host" "if-none-match" "origin" "referer" "user-agent"]   :expose-headers #{"X-Custom"}}
    :methods
    {:get  {:response get-email-campaign}
     :put {:parameters {:body {:name String
                               :geo String
                               :autoaccept Boolean
                               :emails [String]}}
           :consumes   "application/json"
           :response   update-email-campaign}}}))

bradford19:05:24

I also tried {:allow-origin "*" ... but got the same error

shooodooken22:05:14

looking at the schema def for allow-origin here: https://github.com/juxt/yada/blob/f0f010548f7faacd9baa25c9eb7a14aafde0b424/src/yada/schema.clj#L345 ,try to put your domains in a set #{}