···375 if !rp.config.Core.Dev {
376 protocol = "https"
377 }
378+379+ // if the tree path has a trailing slash, let's strip it
380+ // so we don't 404
381+ treePath = strings.TrimSuffix(treePath, "/")
382+383 resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/tree/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref, treePath))
384 if err != nil {
385 log.Println("failed to reach knotserver", err)
386+ return
387+ }
388+389+ // uhhh so knotserver returns a 500 if the entry isn't found in
390+ // the requested tree path, so let's stick to not-OK here.
391+ // we can fix this once we build out the xrpc apis for these operations.
392+ if resp.StatusCode != http.StatusOK {
393+ rp.pages.Error404(w)
394 return
395 }
396···538 resp, err := http.Get(fmt.Sprintf("%s://%s/%s/%s/blob/%s/%s", protocol, f.Knot, f.OwnerDid(), f.Repo.Name, ref, filePath))
539 if err != nil {
540 log.Println("failed to reach knotserver", err)
541+ return
542+ }
543+544+ if resp.StatusCode == http.StatusNotFound {
545+ rp.pages.Error404(w)
546 return
547 }
548