Show 404 error for index.html not found

This commit is contained in:
Yang Luo 2023-10-10 22:57:39 +08:00
parent 684cbdb951
commit 070aa8a65f

View File

@ -77,6 +77,7 @@ func StaticFilter(ctx *context.Context) {
panic(err)
}
dir = strings.ReplaceAll(dir, "\\", "/")
ctx.ResponseWriter.WriteHeader(http.StatusNotFound)
errorText := fmt.Sprintf("The Casdoor frontend HTML file: \"index.html\" was not found, it should be placed at: \"%s/web/build/index.html\". For more information, see: https://casdoor.org/docs/basic/server-installation/#frontend-1", dir)
http.ServeContent(ctx.ResponseWriter, ctx.Request, "Casdoor frontend has encountered error...", time.Now(), strings.NewReader(errorText))
return