如何将 CORS 添加到此代码段?
(def app
(api
{:swagger {:ui "/docs"
:spec "/swagger.json"}}
(GET "/route-a" [] "a")
(GET "/route-b" [] "b")
(GET "/route-c" [] "c")))
我想使用https://github.com/r0man/ring-cors并尝试过这个,但它似乎没有做任何事情。我希望看到响应标头包含 Access-Control-Allow-Origin 但它丢失了。
(-> (api
{:swagger {:ui "/docs"
:spec "/swagger.json"}}
(GET "/route-a" [] "a")
(GET "/route-b" [] "b")
(GET "/route-c" [] "c"))
(wrap-cors :access-control-allow-origin #"http://localhost:81"
:access-control-allow-headers ["Origin" "X-Requested-With"
"Content-Type" "Accept"]
:access-control-allow-methods [:get :put :post :delete :options]))