diff --git a/backend/web/web.go b/backend/web/web.go index 5f06a3a..7994a05 100644 --- a/backend/web/web.go +++ b/backend/web/web.go @@ -4,6 +4,7 @@ import ( "context" "crypto/tls" "embed" + "html/template" "io" "io/fs" "net" @@ -53,6 +54,14 @@ func (s *Server) initRouter() (*gin.Engine, error) { engine := gin.Default() + // Load the HTML template + t := template.New("").Funcs(engine.FuncMap) + template, err := t.ParseFS(content, "html/index.html") + if err != nil { + return nil, err + } + engine.SetHTMLTemplate(template) + base_url, err := s.settingService.GetWebPath() if err != nil { return nil, err @@ -96,9 +105,6 @@ func (s *Server) initRouter() (*gin.Engine, error) { group_api := engine.Group(base_url + "api") api.NewAPIHandler(group_api) - // Load the HTML template - engine.LoadHTMLFiles("backend/web/html/index.html") - // Serve index.html as the entry point // Handle all other routes by serving index.html engine.NoRoute(func(c *gin.Context) {