Fork me on GitHub
#pedestal
<
2021-07-22
>
ChillPillzKillzBillz19:07:54

maybe this is a rookie mistake... but when I try to access the page my pedestal is hosting... I only get the text of the html I am sending as response... instead of the actual page... why?

souenzzo19:07:41

@abhishek.mazy you need to add :headers {"Content-Type" "text/html"} to your response By default, if pedestal find a string on the :body, it will write it as "text/plain"

ChillPillzKillzBillz19:07:58

Many thanks for this!! It is a pity that this is not specified in any of the tutorials/cookbooks... anywho!! Thanks a bunch!!

ChillPillzKillzBillz20:07:37

Another rookie question: I am trying to serve js files generated by figwheel. I am running a simultaneous build environment... or atleast trying to... My Folder structure is as follows: ├───resources │ └───public │ └───css ├───src │ ├───backend │ └───frontend ├───target │ └───public │ └───cljs-out │ └───dev └───test └───frontend Now from pedestal I'd like to supply the css folder in resources/public as well as the cljs-out folder in target/public folder as static resources. I've added both of these paths to my deps.edn such that :paths ["src" "resources" "target/public"] is the definition there. Additionally my service definition is as follows:

(def service {:env                 :prod
              ::http/routes        routes
              ::http/resource-path "public"
              ::http/type          :jetty
              ::http/port          8080
              ::http/secure-headers {:content-security-policy-settings {:object-src "none"}}})
Unfortunately when I access the page, I can't see the cljs-out folder. How can this be done?

souenzzo21:07:40

@abhishek.mazy i personally use ::http/file-path "target/public" I don't like to use :paths [... "folder-with-a-lot-of-gen-things"] because will make this folder be in my classpath and the intellij indexer will blow up

👍 3
ChillPillzKillzBillz09:07:18

Ok so after this do I remove the "folder-with-a-lot-of-gen-things" out of the :paths in deps.edn? Thanks for this I'll give it a try...

ChillPillzKillzBillz09:07:10

I am happy to report that now it is working for me!! 🎉 I didn't have to change the :paths in deps.edn