Ability to serve static files #1174

Merged
konrad merged 3 commits from grahammiln/api:main into main 2022-05-23 20:49:33 +00:00

3 Commits

Author SHA1 Message Date
grahammiln 25325c28f1 Reverted.
continuous-integration/drone/pr Build is passing Details
Reverted, as requested.
2022-05-22 15:37:28 +00:00
Graham Miln b248b98914 Document static path option.
continuous-integration/drone/pr Build is passing Details
2022-05-22 14:46:22 +02:00
Graham Miln d998b8099f Add ability to serve static files.
Added a configuration key, `service.staticpath`, to allow the serving
of files from the provided path. By default, the path is empty and
Vikunja's existing behaviour is unchanged.

Providing a path via the configuration, adds a static file middleware to
serve the path's contents from root (/).

Being able to serve static files allows the api service to also serve
the frontend content. This adds a simple option for deploying Vikunja
without needing any other servers or proxies.

Running a complete instance becomes:

VIKUNJA_SERVICE_STATICPATH=/path/to/frontend ./vikunja

Where /path/to/frontend is a copy of Vikunja's frontend static files.

Future improvements could embed a copy of the frontend files via the
fs.FS and embed package. Alternatively a reverse proxy could be offered
using http/httputil's ReverseProxy; this would allow another server to
maintain a default set of frontend files without embedding.
2022-05-22 14:27:58 +02:00