Skip to content

Commit

Permalink
fix: only attempt _redirects if the path does not exist
Browse files Browse the repository at this point in the history
  • Loading branch information
aschmahmann authored and hacdias committed Jul 31, 2023
1 parent 48cd797 commit 66e17a9
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gateway/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 66e17a9

Please sign in to comment.