diff --git a/config.yml.sample b/config.yml.sample index c4c918ae..0b368866 100644 --- a/config.yml.sample +++ b/config.yml.sample @@ -22,6 +22,8 @@ service: # Vikunja will also look in this path for a config file, so you could provide only this variable to point to a folder # with a config file which will then be used. rootpath: + # Path on the file system to serve static files from. Set to the path of the frontend files to host frontend alongside the api. + staticpath: "" # The max number of items which can be returned per page maxitemsperpage: 50 # Enable the caldav endpoint, see the docs for more details diff --git a/docs/content/doc/setup/config.md b/docs/content/doc/setup/config.md index d297f851..9124b259 100644 --- a/docs/content/doc/setup/config.md +++ b/docs/content/doc/setup/config.md @@ -161,6 +161,17 @@ Full path: `service.rootpath` Environment path: `VIKUNJA_SERVICE_ROOTPATH` +### staticpath + +Path on the file system to serve static files from. Set to the path of the frontend files to host frontend alongside the api. + +Default: `` + +Full path: `service.staticpath` + +Environment path: `VIKUNJA_SERVICE_STATICPATH` + + ### maxitemsperpage The max number of items which can be returned per page @@ -426,16 +437,18 @@ Full path: `database.sslmode` Environment path: `VIKUNJA_DATABASE_SSLMODE` + ### sslcert The path to the client cert. Only used with postgres. - + Default: `` Full path: `database.sslcert` Environment path: `VIKUNJA_DATABASE_SSLCERT` + ### sslkey The path to the client key. Only used with postgres. @@ -446,6 +459,7 @@ Full path: `database.sslkey` Environment path: `VIKUNJA_DATABASE_SSLKEY` + ### sslrootcert The path to the ca cert. Only used with postgres. @@ -456,6 +470,7 @@ Full path: `database.sslrootcert` Environment path: `VIKUNJA_DATABASE_SSLROOTCERT` + ### tls Enable SSL/TLS for mysql connections. Options: false, true, skip-verify, preferred diff --git a/pkg/config/config.go b/pkg/config/config.go index dfde771e..ff40e2cb 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -47,6 +47,7 @@ const ( ServiceFrontendurl Key = `service.frontendurl` ServiceEnableCaldav Key = `service.enablecaldav` ServiceRootpath Key = `service.rootpath` + ServiceStaticpath Key = `service.staticpath` ServiceMaxItemsPerPage Key = `service.maxitemsperpage` // Deprecated: Use metrics.enabled ServiceEnableMetrics Key = `service.enablemetrics` @@ -274,6 +275,7 @@ func InitDefaultConfig() { ServiceEnableCaldav.setDefault(true) ServiceRootpath.setDefault(getBinaryDirLocation()) + ServiceStaticpath.setDefault("") ServiceMaxItemsPerPage.setDefault(50) ServiceEnableMetrics.setDefault(false) ServiceMotd.setDefault("") diff --git a/pkg/routes/routes.go b/pkg/routes/routes.go index d5f79a8c..9c27f9c9 100644 --- a/pkg/routes/routes.go +++ b/pkg/routes/routes.go @@ -203,6 +203,11 @@ func RegisterRoutes(e *echo.Echo) { // healthcheck e.GET("/health", HealthcheckHandler) + // static files + if static := config.ServiceStaticpath.GetString(); static != "" { + e.Use(middleware.Static(static)) + } + // CORS_SHIT if config.CorsEnable.GetBool() { e.Use(middleware.CORSWithConfig(middleware.CORSConfig{