fix: ensure we are talking to coder on first user check (#11130)

This commit is contained in:
Garrett Delfosse
2023-12-11 14:27:32 -05:00
committed by GitHub
parent e37bbe6208
commit b7ea330aea
2 changed files with 43 additions and 0 deletions
+8
View File
@@ -190,7 +190,15 @@ func (c *Client) HasFirstUser(ctx context.Context) (bool, error) {
return false, err
}
defer res.Body.Close()
if res.StatusCode == http.StatusNotFound {
// ensure we are talking to coder and not
// some other service that returns 404
v := res.Header.Get("X-Coder-Build-Version")
if v == "" {
return false, xerrors.Errorf("missing build version header, not a coder instance")
}
return false, nil
}
if res.StatusCode != http.StatusOK {