cryogen-project / cryogen-project/cryogen

Router serving static-file only works locally

Open
#254 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
HTML
Stars
1.1k
Forks
93
PR merge metrics
No merged PRs in 30d

Description

## I want to create a router for /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](https://user-images.githubusercontent.com/59554283/203158399-fe7cb335-b9b7-43ea-8d0d-604388c50365.png)

But, in my website, it gives 404, [www.buddhilw.com/cv1](www.buddhilw.com/cv1).

In the `server.clj`, I defined the router `cv1`, as so:
```clj
(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 ".pdf") and dropping the `(let [config (resolve-config)] ...)` stuff

None worked.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.