This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-05-26
Channels
- # beginners (91)
- # cider (34)
- # cljsrn (6)
- # clojure (95)
- # clojure-gamedev (4)
- # clojure-serbia (7)
- # clojure-spec (5)
- # clojure-uk (27)
- # clojurescript (42)
- # data-science (1)
- # datascript (2)
- # datomic (4)
- # duct (10)
- # emacs (11)
- # fulcro (21)
- # luminus (3)
- # lumo (24)
- # off-topic (2)
- # other-languages (2)
- # ring (2)
- # shadow-cljs (39)
- # spacemacs (9)
- # tools-deps (2)
I've got some questions about deployment. I've uberjarred up my web application and I'm using caddy to reverse proxy traffic to it, however all the absolute links are broken - for example loading my css file ("/css/site.css") and js file ("/js/app.js")
I know this isn't strictly a clojure problem, but maybe someone here has some experience with it
@datran what do you mean by "broken"?
how did you start your uberjarred app?
is it in your local machine or on a server elsewhere?
let's assume you started your app on the server on port 8080
and you ssh into the server, try curl localhost:8080/css/site.css
is it 304 or 200?
good, so it's up
may I see your caddyfile?
let me see...
I added the 'without' line to see if that would help, but it didn't seem to make any difference
without is for part of the request uri, not the base url (aka domain) part
I did just find this: https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy#561897
I might try just changing the links I have to stuff in my /public folder to be relative urls
indeed it's a good practise, server softwares like nginx & caddy are better at serving assets than jetty/netty
when I try just putting the full relative url into the link, that's a 404, it can't find it (resources/public/css/site.css)
which makes some sense because when it's all uberjarred up I don't think it has the same root
the part resources/public is java/clojure thing. It's the ring middleware that serve it to the outside world
yup, it's just a zip
hmm, what does your html head part look like? <link rel="stylesheet" href="">
what's in that href?
(hic/include-css "public/css/site.css")] ;=> <link href="public/css/site.css" rel="stylesheet" type="text/css">
what's that in your public http://example.com site?
here's the live link if you want to see: https://shove-tussle.idle.horse/
wait, you said 304, not 404 right?
your asset links look normal
304 is expected
it means "resource has not been modified since last requested"
I guess as Caddy see the files haven't been changed, it tells browsers to use cached version
and when I actually view the source (at least for the css, the js is compiled with {:optimizations :advanced}, so lord knows what that should look like), it shows the correct file
well, I think that means that the problem firmly lives in my code, so I'll just have to make sure I'm actually calling the start function
my console shows "SecurityError: The operation is insecure."
maybe something not allowed with https?
enable http version of the app and see if it works
do you know how to do that? I can look it up if you don't have it on the tip of your head
please help look it up 😄
my caddy understanding is a lazy sequence 😄
> Mixed Content: The page at 'https://shove-tussle.idle.horse/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint '<ws://shove-tussle.idle.horse/ws>'. This request has been blocked; this endpoint must be available over WSS.
🙂 you found it
why dns matters here?
ok, so it looks like I can fix it by using wss:// instead of ws://, but then I'll need a security cert for dev work, which I don't really like
I'm going to do a bit more reading in the hopes that I can accomplish what I want just in caddy, but I'm growing skeptical
ok, I think I'm just going to change my app to connect securely or not based on whether it's a prod build or not. But I'm off to bed. Thanks!
is there a shortcut for (doall (for
?
I don't think so. You could define your own macro to do that, of course, if you use it that combo very commonly.
@joelsanchez Depending on how complex your for
expression is, maybe (into [] xf coll)
would be clearer in intent? I used to use doall
a lot when I first started with Clojure, trying to avoid tripping over lazy sequences, but now I feel that doall
is a bit of a code smell...
doall
is a bit of a code smell indeed but re-frame requires avoiding the laziness for subscriptions @seancorfield
I tend to rewrite using mapv
sometimes but it's usually less readable (as UI code)
Yeah, for
can be very expressive...
I think I can write a forv
helper tho 🙂 thanks
If I want to flip all bits, like the ~ operate in java.... is there a fn? We have flip-bit
which takes an index, but I want flip-bits
- flip all of them?
bit-not
, found it in https://clojure.org/api/cheatsheet
pretty cool tutorial http://cek.io/blog/2017/08/17/clojure-introduction-binary-bitwise/
Well, figured out the clk_slack part...
clj-slack.core=> (for [user-id (range 1 500)]
#_=> (nth (get (clj-slack.core/slack-request connection "users.list" {:presence "true"}) :members) user-id)
#_=> )
ExceptionInfo clj-http: status 429 slingshot.support/stack-trace (support.clj:201)
Ugh. Damn 429