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 committed Jul 26, 2023
1 parent a8d5f27 commit 34078aa
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
}

Check warning on line 756 in gateway/handler.go

View check run for this annotation

Codecov / codecov/patch

gateway/handler.go#L753-L756

Added lines #L753 - L756 were not covered by tests

// 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 34078aa

Please sign in to comment.