Skip to content

Commit

Permalink
I think this solves the CORS bug
Browse files Browse the repository at this point in the history
  • Loading branch information
adamjohnwright committed Feb 18, 2021
1 parent 0181dfc commit 8c4c8ef
Showing 1 changed file with 30 additions and 34 deletions.
64 changes: 30 additions & 34 deletions src/rest_api/main.clj
Original file line number Diff line number Diff line change
Expand Up @@ -126,39 +126,35 @@
[]
(mount/start))

(def cors-policy
{:access-control-allow-origin [#".*"]
:access-control-allow-methods [:get]})

(def app
"Entry-point for ring request handler."
(sweet/api
{:swagger
{:ui "/"
:spec "/swagger.json"
:formats {:format api-output-formats}
:coercion nil
:consumes nil
:produces api-output-formats
:definitions {}
:options
{:ui
{:validatorUrl swagger-validator-url}}
:data
{:info
{:title "WormBase REST API"
:description
(str "Widget and field endpoints "
"used by the official [WormBase]"
"(http://www.wormbase.org) site.")
:contact {:name "the WormBase development team"
:email "[email protected]"}
:version (pace-utils/package-version "wormbase/rest-api")}}}}
(sweet/context "/" []
:middleware [ring-gzip/wrap-gzip wrap-not-found]
(sweet/context "/rest" []
(as-> all-routes handler
(flatten handler)
(apply sweet/routes handler)
; (apply wrap-cors handler (into [] cat cors-policy))
)))))
(-> (sweet/api
{:swagger
{:ui "/"
:spec "/swagger.json"
:formats {:format api-output-formats}
:coercion nil
:consumes nil
:produces api-output-formats
:definitions {}
:options
{:ui
{:validatorUrl swagger-validator-url}}
:data
{:info
{:title "WormBase REST API"
:description
(str "Widget and field endpoints "
"used by the official [WormBase]"
"(http://www.wormbase.org) site.")
:contact {:name "the WormBase development team"
:email "[email protected]"}
:version (pace-utils/package-version "wormbase/rest-api")}}}}
(sweet/context "/" []
:middleware [ring-gzip/wrap-gzip wrap-not-found]
(sweet/context "/rest" []
(->> all-routes
(flatten)
(apply sweet/routes)))))
(wrap-cors :access-control-allow-origin [#".*"]
:access-control-allow-methods [:get])))

0 comments on commit 8c4c8ef

Please sign in to comment.