Skip to content

Router serving static-file only works locally #254

@BuddhiLW

Description

@BuddhiLW

I want to create a router for <website.com>/cv1 and serve a pdf.

Locally, it works just fine. That is, curl will work. And, the page renders a pdf on the browser.

Locally:
maim-region-20221121-180237

But, in my website, it gives 404, www.buddhilw.com/cv1.

In the server.clj, I defined the router cv1, as so:

(defroutes routes
  (GET "/" [] (redirect
               (let [config (resolve-config)]
                 (path (:blog-prefix config)
                       (when (= (:clean-urls config) :dirty)
                         "index.html")))))
  (GET "/cv1" [] (ring.util.response/file-response
                              (let [config (resolve-config)]
                                  (path (:blog-prefix config)
                                             "cv-2022-11-03.pdf"))))
  (route/files "/")
  (route/not-found "Page not found"))

What could I do to accomplish the file-serving?

What I have tried

  • I tried prefixing, and creating a different end-point for each. So, public/pdf/.pdf, /pdf/.pfg, .pdf.
  • I tried copying the file in all possible directories, public/pdf, root, or content/pdf.
  • Using only (path "<path>.pdf") and dropping the (let [config (resolve-config)] ...)` stuff

None worked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions