Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c638800

Browse files
committed
fix: make non-existent asset paths return a 404
Before, if a file was not found we would serve the app.
1 parent f24cb5c commit c638800

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

site/site.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ func (h *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
205205
case reqFile == "bin" || strings.HasPrefix(reqFile, "bin/"):
206206
h.handler.ServeHTTP(rw, r)
207207
return
208-
// If the original file path exists we serve it.
209-
case h.exists(reqFile):
208+
// If the original file path exists or requesting assets we serve it.
209+
case h.exists(reqFile),
210+
reqFile == "assets" || strings.HasPrefix(reqFile, "assets/"):
210211
if ShouldCacheFile(reqFile) {
211212
rw.Header().Add("Cache-Control", "public, max-age=31536000, immutable")
212213
}

0 commit comments

Comments
 (0)