This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-15
Channels
- # aws (25)
- # babashka (11)
- # beginners (24)
- # calva (18)
- # clj-kondo (6)
- # cljdoc (1)
- # clojure (48)
- # clojure-europe (3)
- # clojure-houston (1)
- # clojure-uk (22)
- # clojuredesign-podcast (8)
- # clojurescript (9)
- # cursive (8)
- # dirac (6)
- # duct (19)
- # fulcro (17)
- # hoplon (29)
- # mount (3)
- # off-topic (24)
- # pathom (6)
- # re-frame (6)
- # shadow-cljs (5)
- # spacemacs (5)
- # sql (10)
- # tools-deps (7)
- # vim (2)
From what I understand, using absolute paths, or "lobalhost:port" is bad practice in production. Is there an example how do I make my re-frame app use relative paths for my api? e.g instead of: (fun-with-api "http://example.com/api/fun") or (fun-with-api "http://localhost:1234/api/fun") I could do something like (fun-with-api "/api/fun")
If so, then the question in the OP is answered by the OP. Yes, you just use something like "/api/fun"
.
Oh, thats good to know, thanks 🙂 I realize I didn't define my problem correctly, I need to connect to a backend websocket api on the same server, the solution may be: a. using a url variable in a config file b. using (. (. js/window -location) -host) :)
I have used the js/window solution before, but then I moved things into containers and broke it all. To keep it flexible I put env specific configuration into environment vars and in my http://nginx.conf I serve an endpoint there. That way I can setup an endpoint in my reframe for /server that in dev serves a hard coded file, but in staging or prod serves something based on the end var eg API_ENDPOINT. Can post an example if it helps.