This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-11-24
Channels
- # aws (14)
- # beginners (111)
- # boot (12)
- # cider (1)
- # cljsrn (7)
- # clojure (65)
- # clojure-dusseldorf (1)
- # clojure-germany (7)
- # clojure-greece (10)
- # clojure-italy (13)
- # clojure-poland (7)
- # clojure-russia (7)
- # clojure-spec (53)
- # clojure-uk (29)
- # clojurescript (27)
- # community-development (9)
- # cursive (2)
- # data-science (1)
- # datomic (17)
- # emacs (16)
- # events (6)
- # fulcro (155)
- # graphql (8)
- # instaparse (1)
- # leiningen (30)
- # lumo (29)
- # om-next (3)
- # other-languages (46)
- # pedestal (11)
- # portkey (7)
- # re-frame (13)
- # reagent (6)
- # ring (8)
- # rum (1)
- # shadow-cljs (75)
- # sql (1)
- # timbre (3)
- # unrepl (128)
Hey everyone, I'm super new to clojure, trying to set up a super basic graphql server with lacinia and lacinia-pedestal but I'm getting CORs errors, anyone have any experience getting cors working with lacinia-pedestal?
(ns user
"The user gets loaded by the repl by default, just helps with testing queries out..."
(:require [api.schema :as s]
[com.walmartlabs.lacinia :as lacinia]
[com.walmartlabs.lacinia.pedestal :as lp]
[io.pedestal.http :as http]
[clojure.walk :as walk])
(:import (clojure.lang IPersistentMap)))
...
(defn start-server
[_]
(-> schema
(lp/pedestal-service {:graphiql true})
http/create-server
http/start))
I've tried doing something like:
(defn start-server
[_]
( as-> schema pipe-val
(lp/pedestal-service pipe-val {:graphiql true})
(merge pipe-val { ::http/allowed-origins { :allowed-origins (constantly true)}})
(http/create-server pipe-val)
(http/start pipe-val)))
And it doesn't seem to work@amilner42 You may have already looked at this, but if not… https://github.com/pedestal/pedestal/tree/master/samples/cors
That was how I came up with what I tried :S … This is the first code I ever wrote in clojure so I’m kinda learning as I go…
Based on: https://github.com/pedestal/pedestal/blob/master/samples/cors/src/cors/server.clj#L34
@amilner42 Can't do much for you at the moment: I'm sitting in a general store near Lancaster, PA, waiting for my wife. I recall a CORS setting or interceptor in code generated by lein vase
for a Vase project. Might be worth looking at it.
Oh I think this worked:
(defn start-server
[_]
(-> schema
(lp/service-map {:graphiql true})
(merge { ::http/allowed-origins {:creds true :allowed-origins (constantly true)}})
http/create-server
http/start))
It looks like lp/pedestal-service
was calling create-server
, so that’s why it wasn’t working…