3
0

Fix auth asset embeding & serving

This commit is contained in:
Denis Arh
2021-03-08 16:23:56 +01:00
parent cbc5034e8f
commit 2972437421
4 changed files with 5 additions and 5 deletions

View File

@@ -294,8 +294,8 @@ func (svc service) MountHttpRoutes(r chi.Router) {
svc.handlers.MountHttpRoutes(r)
const uriRoot = "/auth/assets/public"
if len(svc.opt.AssetsPath) == 0 {
r.Handle(uriRoot+"/*", http.StripPrefix("/auth/assets", http.FileServer(http.FS(publicAssets))))
if len(svc.opt.AssetsPath) == 0 && !svc.opt.DevelopmentMode {
r.Handle(uriRoot+"/*", http.StripPrefix("/auth/", http.FileServer(http.FS(publicAssets))))
} else {
var root = strings.TrimRight(svc.opt.AssetsPath, "/") + "/public"
r.Handle(uriRoot+"/*", http.StripPrefix(uriRoot, http.FileServer(http.Dir(root))))

View File

@@ -62,5 +62,5 @@ func (t templateStatic) ExecuteTemplate(w io.Writer, name string, data interface
// EmbeddedTemplates returns embedded templates.
func EmbeddedTemplates(t *template.Template) (tpl *template.Template, err error) {
return t.ParseFS(embeddedTemplates, "templates/*.html.tpl")
return t.ParseFS(embeddedTemplates, "assets/templates/*.html.tpl")
}

View File

@@ -60,7 +60,7 @@ func Auth() (o *AuthOpt) {
CsrfFieldName: "same-site-authenticity-token",
CsrfCookieName: "same-site-authenticity-token",
DefaultClient: "corteza-webapp",
AssetsPath: "auth/assets",
AssetsPath: "",
}
fill(o)

View File

@@ -135,7 +135,7 @@ props:
the need to suply redirection URL and client ID (oauth2/go endpoint does that internally)
- name: assetsPath
default: "auth/assets"
default: ""
description: |-
Path to js, css, images and template source files