Fork me on GitHub
#re-frame
<
2020-03-15
>
Oz11:03:31

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")

p-himik11:03:49

What is "re-frame pp"?

dominicm11:03:49

Typo of app I suspect

p-himik11:03:55

If so, then the question in the OP is answered by the OP. Yes, you just use something like "/api/fun".

Oz12:03:33

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) :)

Jag Gunawardana23:03:15

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.

👍 4