Fork me on GitHub
#pedestal
<
2022-06-24
>
simongray08:06:41

I am trying to transform my production web service from using clojure to compiling an uberjar and running this using java -jar . Apparently, this is wreaking havoc on file access! The latest issue I am running into is that rather than serving my main.css, which is served fine when running in the REPL, I get servedanother main.css from the resource path. This other main.css is brought in by a library. I have have this set in my context map:

::http/resource-path  "/public"
In my HTML I have <link href="/css/main.css" rel="stylesheet"> , but Pedestal fetches the resource at /public/css/main.css rather than the file in the same path.

simongray08:06:53

TL;DR Pedestal serves me random resources in libraries rather than the CSS file that’s on disk. How can I make it serve me files on disk?

simongray08:06:55

Do I seriously need to write a custom classloader just to get Pedestal to prefer files on disk…? 😮

rolt09:06:29

i'm not entirely sure, but have you tried ::http/file-path ?

simongray09:06:14

@rolthiolliere oh, I did not know about this. Gonna try this out! Thanks.

rolt09:06:15

however if the css file is linked to the app you may want to deliver it the the jar as a resource anyway. I would assume that if you set the resource path correctly in the uberjar conf it would prefer the app's resources to a lib's resources when there is a conflict

👍 1
🙏 1
simongray09:06:54

Yeah, I learned some more about resource paths over in #clojure-europe so I guess I can just make a different directory structure to avoid the shadowing entirely: https://clojurians.slack.com/archives/CBJ5CGE0G/p1656063632492859