dwyl / learn-phoenix-framework

:fire: Phoenix is the web framework without compromise on speed, reliability or maintainability! Don't settle for less. :rocket:
648 stars 45 forks source link

How to serve a specific static file (not CSS, JS or images) in `Phoenix`? #155

Open nelsonic opened 1 year ago

nelsonic commented 1 year ago

I would like a easy/simple way to serve a static file in a Phoenix App e.g: when you need to verify a domain the registrar requires a .txt file. This can sometimes be done at the DNS level. But other times it needs to be served by the Application.

My particular use case is the following: I want to serve a copy of the mix.lock file from the project so that I can easily see exactly which version of a dependency is running.

In the past we have served an endpoint that displayed the Git version of the App that we could then lookup on GitHub to determine exactly which version of the App was running for debugging purposes.

e.g: router.ex#L104-L106 and controllers/github_version_controller.ex

Problem is: I don't think the Git history is available on Fly.io (it wasn't on Heroku ...) So I think the easiest thing is to serve a static file. 📁

Very grateful for any insight other people using Phoenix have on this. 💭 💬 🙏

nelsonic commented 1 year ago

https://elixirforum.com/t/serving-static-files-from-a-phoenix-api/46089/2