This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-17
Channels
- # adventofcode (23)
- # announcements (2)
- # aws (11)
- # babashka (181)
- # beginners (59)
- # chestnut (2)
- # clj-kondo (9)
- # clojure (90)
- # clojure-brasil (2)
- # clojure-europe (18)
- # clojure-italy (24)
- # clojure-nl (9)
- # clojure-spec (3)
- # clojure-uk (28)
- # clojured (4)
- # clojuredesign-podcast (3)
- # clojurescript (12)
- # community-development (49)
- # core-async (49)
- # cryogen (5)
- # cursive (16)
- # data-science (1)
- # datascript (7)
- # datomic (54)
- # defnpodcast (4)
- # events (2)
- # figwheel-main (14)
- # fulcro (139)
- # graphql (1)
- # jobs-discuss (6)
- # kaocha (1)
- # luminus (2)
- # malli (3)
- # music (1)
- # off-topic (34)
- # pathom (24)
- # re-frame (13)
- # reitit (5)
- # shadow-cljs (8)
- # test-check (6)
I have a website which talks to an API backend, both are CLJS using shadow. In my pages I make calls to the backend, in production they will call https://<my-domain>/path
, but in local dev I want them to call
. Is there a tidy way to do this? I thought about using the hosts file but that doesn’t allow me to switch from https to http or specify the port to use.
Actually it looks like Closure defines would work for this. So am I correct in thinking that if I do this:
(goog-define LOCAL true)
(def api-target (if LOCAL "<local-url>" "<prod-url>")
Then only one of those values will be compiled into the code? Or am I better to have the URL itself as the value of the define?Yes your correct only one value should be compiled in when using Closure defines.
Personally I inject the entire URL, instead of just a boolean, but I believe either way will have the same result i.e. only one value compiled in to the output JS.
@U0G75S29H Thanks, yes, that’s what I ended up with, which seems to work well.
Anytime @U0567Q30W 🙂 Thank you for Cursive! I spend about 50% of my time awake using it.