Fork me on GitHub

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.


Great, I’m glad you’re still liking it!


what’s the purpose of the ^clj type hint?