fukamachi / caveman

Lightweight web application framework for Common Lisp.
http://8arrow.org/caveman/
775 stars 63 forks source link

set content-type for css when using a different template library #140

Open mooseyboots opened 1 year ago

mooseyboots commented 1 year ago

i was trying out ningle with spinneret, then thought to try caveman with spinneret also. i'm having trouble with handling static resources though.

if i take the caveman skeleton project, and change the main route to be:

(defroute "/" ()
  (spinneret:with-html-string
    (:doctype)
    (:html
     (:head
      (:title "test")
      (:link :type "image/png" :rel "icon" :href "/favicon.png")
      (:link :type "text/css" :rel "stylesheet" :href "main.css")
     (:body
      (:h1 "my stuff")

the css doesn't load, and the browser console errors:

The resource from “http://localhost:5000/main.css” was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).`

I'm unsure how to set the content-type in this case, as i'm trying to handle different types in the one route. is it not possible to write routes like this?

mooseyboots commented 1 year ago

i tried out the cl-who who library mentioned in the readme, and i have the same issue.

vindarel commented 1 year ago

Is it working with the default Caveman, using Djula templates?

Did you write something more, a route definition?

set content-type for css

I don't think you'd write a route and set the content type, but you'd configure the web server (Clack) to serve static assets from a directory. That seems to be done by default somewhere.

(not a Caveman connoisseur, helping you brainstorm)

mooseyboots commented 1 year ago

hi @vindarel thanks for chiming in. (and for all your CL resources! they're great, CL needs lots more docs for newcomers, and i say that as sb who knows lisp but not CL specifically.)

yes static assets work with the default set up. that's actually why i tried this out as i had trouble getting ningle to work with static assets and spinneret.

for now i have solved the issue using ningle, after lots of tears.

it would be good for more ningle/caveman/clack/lack to have more documentation. i all they have and after about 10 minutes of hacking i had already run into issues the docs don't mention at all.