- commit
- 56b4fc7
- parent
- 162bd66
- author
- Eric Bower
- date
- 2025-04-10 15:48:01 -0400 EDT
fix(pgs): use custom 404 when trying to access special file
2 files changed,
+7,
-7
+0,
-6
1@@ -445,12 +445,6 @@ func (web *WebRouter) ServeAsset(fname string, opts *storage.ImgProcessOpts, fro
2 "host", r.Host,
3 )
4
5- if isSpecialFile(fname) {
6- logger.Info("special file names are not allowed to be served over http")
7- http.Error(w, "404 not found", http.StatusNotFound)
8- return
9- }
10-
11 props, err := shared.GetProjectFromSubdomain(subdomain)
12 if err != nil {
13 logger.Info(
+7,
-1
1@@ -76,7 +76,13 @@ func (h *ApiAssetHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
2 h.RedirectsCache.Add(redirectsCacheKey, redirects)
3 }
4
5- routes := calcRoutes(h.ProjectDir, h.Filepath, redirects)
6+ fpath := h.Filepath
7+ if isSpecialFile(fpath) {
8+ logger.Info("special file names are not allowed to be served over http")
9+ fpath = "404.html"
10+ }
11+
12+ routes := calcRoutes(h.ProjectDir, fpath, redirects)
13
14 var contents io.ReadCloser
15 assetFilepath := ""