From 34078aa1c4341240dbad43ebb687a185463d0648 Mon Sep 17 00:00:00 2001 From: Adin Schmahmann Date: Wed, 26 Jul 2023 05:58:51 -0400 Subject: [PATCH] fix: only attempt _redirects if the path does not exist --- gateway/handler.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gateway/handler.go b/gateway/handler.go index 472068df7..fb1f9c7d9 100644 --- a/gateway/handler.go +++ b/gateway/handler.go @@ -748,6 +748,13 @@ func (i *handler) handleWebRequestErrors(w http.ResponseWriter, r *http.Request, return ImmutablePath{}, false } + // If the error is not an IPLD traversal error then we should not be looking for _redirects or legacy 404s + if !isErrNotFound(err) { + err = fmt.Errorf("failed to resolve %s: %w", debugStr(contentPath.String()), err) + i.webError(w, r, err, http.StatusInternalServerError) + return ImmutablePath{}, false + } + // If we have origin isolation (subdomain gw, DNSLink website), // and response type is UnixFS (default for website hosting) // we can leverage the presence of an _redirects file and apply rules defined there.