Skip to content

Commit

Permalink
feat: 404 页面均转向至首页
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Apr 17, 2024
1 parent b017941 commit de971b3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/controller/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ func NewApiController(
c.Next()
return
}
http.ServeFile(c.Writer, c.Request, "./frontend/dist"+c.Request.URL.Path)
// 没有文件都返回/
if util.IsFileExist("./frontend/dist"+c.Request.URL.Path) == false {
http.ServeFile(c.Writer, c.Request, "./frontend/dist/index.html")
} else {
http.ServeFile(c.Writer, c.Request, "./frontend/dist"+c.Request.URL.Path)
}
})

rg := r.Group("/v1")
Expand Down

0 comments on commit de971b3

Please sign in to comment.