Repository: supabase/cli
Pull request #866 (2023-02-15 07:38:07)

chore: change API host to `https://api.supabase.com`


Patch:
diff --git a/internal/utils/api.go b/internal/utils/api.go
index 58512908..e765666a 100644
--- a/internal/utils/api.go
+++ b/internal/utils/api.go
@@ -199,6 +199,12 @@ func GetSupabase() *supabase.ClientWithResponses {
 	return apiClient
 }
 
+const (
+	DefaultApiHost = "https://api.supabase.com"
+	// DEPRECATED
+	DeprecatedApiHost = "https://api.supabase.io"
+)
+
 var RegionMap = map[string]string{
 	"ap-northeast-1": "Northeast Asia (Tokyo)",
 	"ap-northeast-2": "Northeast Asia (Seoul)",
@@ -218,14 +224,14 @@ var RegionMap = map[string]string{
 func GetSupabaseAPIHost() string {
 	apiHost := viper.GetString("INTERNAL_API_HOST")
 	if apiHost == "" {
-		apiHost = "https://api.supabase.io"
+		apiHost = DefaultApiHost
 	}
 	return apiHost
 }
 
 func GetSupabaseDashboardURL() string {
 	switch GetSupabaseAPIHost() {
-	case "https://api.supabase.com", "https://api.supabase.io":
+	case DefaultApiHost, DeprecatedApiHost:
 		return "https://app.supabase.com"
 	case "https://api.supabase.green":
 		return "https://app.supabase.green"
@@ -237,7 +243,7 @@ func GetSupabaseDashboardURL() string {
 func GetSupabaseDbHost(projectRef string) string {
 	// TODO: query projects api for db_host
 	switch GetSupabaseAPIHost() {
-	case "https://api.supabase.com", "https://api.supabase.io":
+	case DefaultApiHost, DeprecatedApiHost:
 		return fmt.Sprintf("db.%s.supabase.co", projectRef)
 	case "https://api.supabase.green":
 		return fmt.Sprintf("db.%s.supabase.red", projectRef)
@@ -248,7 +254,7 @@ func GetSupabaseDbHost(projectRef string) string {
 
 func GetSupabaseHost(projectRef string) string {
 	switch GetSupabaseAPIHost() {
-	case "https://api.supabase.com", "https://api.supabase.io":
+	case DefaultApiHost, DeprecatedApiHost:
 		return fmt.Sprintf("%s.supabase.co", projectRef)
 	case "https://api.supabase.green":
 		return fmt.Sprintf("%s.supabase.red", projectRef)


Test patch:
diff --git a/internal/functions/delete/delete_test.go b/internal/functions/delete/delete_test.go
index 1667e7ef..d06be0d6 100644
--- a/internal/functions/delete/delete_test.go
+++ b/internal/functions/delete/delete_test.go
@@ -27,11 +27,11 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusOK)
 		// Run test
@@ -81,7 +81,7 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -101,7 +101,7 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusServiceUnavailable)
 		// Run test
@@ -121,7 +121,7 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusNotFound)
 		// Run test
@@ -141,11 +141,11 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusServiceUnavailable)
 		// Run test
@@ -165,11 +165,11 @@ func TestDeleteCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/test-func").
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/functions/test-func").
 			ReplyError(errors.New("network error"))
 		// Run test
diff --git a/internal/functions/deploy/deploy_test.go b/internal/functions/deploy/deploy_test.go
index 7d1ef9c9..5c51588a 100644
--- a/internal/functions/deploy/deploy_test.go
+++ b/internal/functions/deploy/deploy_test.go
@@ -57,10 +57,10 @@ func TestDeployCommand(t *testing.T) {
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			Reply(http.StatusCreated).
 			JSON(api.FunctionResponse{Id: "1"})
@@ -85,10 +85,10 @@ func TestDeployCommand(t *testing.T) {
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			Reply(http.StatusCreated).
 			JSON(api.FunctionResponse{Id: "1"})
@@ -114,11 +114,11 @@ func TestDeployCommand(t *testing.T) {
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Patch("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
@@ -143,11 +143,11 @@ func TestDeployCommand(t *testing.T) {
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Patch("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
@@ -281,10 +281,10 @@ verify_jwt = false
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			AddMatcher(func(req *http.Request, ereq *gock.Request) (bool, error) {
 				body, err := io.ReadAll(req.Body)
@@ -331,10 +331,10 @@ verify_jwt = false
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			AddMatcher(func(req *http.Request, ereq *gock.Request) (bool, error) {
 				body, err := io.ReadAll(req.Body)
@@ -375,10 +375,10 @@ verify_jwt = false
 		require.NoError(t, err)
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/"+project+"/functions").
 			MatchParam("import_map", "true").
 			Reply(http.StatusCreated).
@@ -402,7 +402,7 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on network failure", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -414,7 +414,7 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on service unavailable", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusServiceUnavailable)
 		// Run test
@@ -426,10 +426,10 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on create failure", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -441,10 +441,10 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on create unavailable", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusNotFound)
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/functions").
 			Reply(http.StatusServiceUnavailable)
 		// Run test
@@ -456,11 +456,11 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on update failure", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Patch("/v1/projects/" + project + "/functions/" + slug).
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -472,11 +472,11 @@ func TestDeployFunction(t *testing.T) {
 	t.Run("throws error on update unavailable", func(t *testing.T) {
 		// Setup mock api
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusOK).
 			JSON(api.FunctionResponse{Id: "1"})
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Patch("/v1/projects/" + project + "/functions/" + slug).
 			Reply(http.StatusServiceUnavailable)
 		// Run test
diff --git a/internal/gen/types/typescript/typescript_test.go b/internal/gen/types/typescript/typescript_test.go
index 6a4b5608..15ffd819 100644
--- a/internal/gen/types/typescript/typescript_test.go
+++ b/internal/gen/types/typescript/typescript_test.go
@@ -92,7 +92,7 @@ func TestGenLinkedCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + projectId + "/types/typescript").
 			Reply(200).
 			JSON(api.TypescriptResponse{Types: ""})
@@ -137,7 +137,7 @@ func TestGenLinkedCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + projectId + "/types/typescript").
 			ReplyError(errors.New("network failure"))
 		// Run test
@@ -159,7 +159,7 @@ func TestGenProjectIdCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + projectId + "/types/typescript").
 			Reply(200).
 			JSON(api.TypescriptResponse{Types: ""})
@@ -188,7 +188,7 @@ func TestGenProjectIdCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + projectId + "/types/typescript").
 			ReplyError(errors.New("network failure"))
 		// Run test
diff --git a/internal/link/link_test.go b/internal/link/link_test.go
index 3977346d..665fac65 100644
--- a/internal/link/link_test.go
+++ b/internal/link/link_test.go
@@ -120,7 +120,7 @@ func TestLinkCommand(t *testing.T) {
 			Reply("CREATE TABLE")
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(200).
 			JSON(api.PostgrestConfigResponse{})
@@ -140,7 +140,7 @@ func TestLinkCommand(t *testing.T) {
 		fsys := afero.NewMemMapFs()
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -154,7 +154,7 @@ func TestLinkCommand(t *testing.T) {
 		fsys := afero.NewMemMapFs()
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(200).
 			JSON(api.PostgrestConfigResponse{})
@@ -173,7 +173,7 @@ func TestLinkCommand(t *testing.T) {
 		fsys := afero.NewReadOnlyFs(afero.NewMemMapFs())
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(200).
 			JSON(api.PostgrestConfigResponse{})
@@ -205,7 +205,7 @@ func TestLinkPostgrest(t *testing.T) {
 	t.Run("ignores matching config", func(t *testing.T) {
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(200).
 			JSON(api.PostgrestConfigResponse{})
@@ -220,7 +220,7 @@ func TestLinkPostgrest(t *testing.T) {
 	t.Run("updates api on newer config", func(t *testing.T) {
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(200).
 			JSON(api.PostgrestConfigResponse{
@@ -244,7 +244,7 @@ func TestLinkPostgrest(t *testing.T) {
 	t.Run("throws error on network failure", func(t *testing.T) {
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -257,7 +257,7 @@ func TestLinkPostgrest(t *testing.T) {
 	t.Run("throws error on server unavailable", func(t *testing.T) {
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/postgrest").
 			Reply(500).
 			JSON(map[string]string{"message": "unavailable"})
diff --git a/internal/orgs/list/list_test.go b/internal/orgs/list/list_test.go
index a06af2fa..804f0712 100644
--- a/internal/orgs/list/list_test.go
+++ b/internal/orgs/list/list_test.go
@@ -8,6 +8,7 @@ import (
 	"github.com/spf13/afero"
 	"github.com/stretchr/testify/assert"
 	"github.com/supabase/cli/internal/testing/apitest"
+	"github.com/supabase/cli/internal/utils"
 	"gopkg.in/h2non/gock.v1"
 )
 
@@ -20,7 +21,7 @@ func TestOrganizationListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/organizations").
 			Reply(200).
 			JSON([]Organization{
@@ -47,7 +48,7 @@ func TestOrganizationListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/organizations").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -64,7 +65,7 @@ func TestOrganizationListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/organizations").
 			Reply(500).
 			JSON(map[string]string{"message": "unavailable"})
@@ -82,7 +83,7 @@ func TestOrganizationListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/organizations").
 			Reply(200).
 			JSON(map[string]string{})
diff --git a/internal/projects/create/create_test.go b/internal/projects/create/create_test.go
index c2f94183..07d62d73 100644
--- a/internal/projects/create/create_test.go
+++ b/internal/projects/create/create_test.go
@@ -8,6 +8,7 @@ import (
 	"github.com/spf13/afero"
 	"github.com/stretchr/testify/assert"
 	"github.com/supabase/cli/internal/testing/apitest"
+	"github.com/supabase/cli/internal/utils"
 	"github.com/supabase/cli/pkg/api"
 	"gopkg.in/h2non/gock.v1"
 )
@@ -29,7 +30,7 @@ func TestProjectCreateCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects").
 			MatchType("json").
 			JSON(params).
@@ -59,7 +60,7 @@ func TestProjectCreateCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects").
 			MatchType("json").
 			JSON(params).
@@ -78,7 +79,7 @@ func TestProjectCreateCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects").
 			MatchType("json").
 			JSON(params).
@@ -98,7 +99,7 @@ func TestProjectCreateCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects").
 			MatchType("json").
 			JSON(params).
diff --git a/internal/projects/list/list_test.go b/internal/projects/list/list_test.go
index 88352c2f..1fab7fe4 100644
--- a/internal/projects/list/list_test.go
+++ b/internal/projects/list/list_test.go
@@ -8,6 +8,7 @@ import (
 	"github.com/spf13/afero"
 	"github.com/stretchr/testify/assert"
 	"github.com/supabase/cli/internal/testing/apitest"
+	"github.com/supabase/cli/internal/utils"
 	"github.com/supabase/cli/pkg/api"
 	"gopkg.in/h2non/gock.v1"
 )
@@ -21,7 +22,7 @@ func TestProjectListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects").
 			Reply(200).
 			JSON([]api.ProjectResponse{
@@ -51,7 +52,7 @@ func TestProjectListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -68,7 +69,7 @@ func TestProjectListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects").
 			Reply(500).
 			JSON(map[string]string{"message": "unavailable"})
@@ -86,7 +87,7 @@ func TestProjectListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects").
 			Reply(200).
 			JSON(map[string]string{})
diff --git a/internal/secrets/list/list_test.go b/internal/secrets/list/list_test.go
index 18aa9d47..99bcb4e4 100644
--- a/internal/secrets/list/list_test.go
+++ b/internal/secrets/list/list_test.go
@@ -29,7 +29,7 @@ func TestSecretListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/secrets").
 			Reply(200).
 			JSON(api.CreateSecretsJSONBody{
@@ -82,7 +82,7 @@ func TestSecretListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/secrets").
 			ReplyError(errors.New("network error"))
 		// Run test
@@ -105,7 +105,7 @@ func TestSecretListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/secrets").
 			Reply(500).
 			JSON(map[string]string{"message": "unavailable"})
@@ -129,7 +129,7 @@ func TestSecretListCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Get("/v1/projects/" + project + "/secrets").
 			Reply(200).
 			JSON(map[string]string{})
diff --git a/internal/secrets/set/set_test.go b/internal/secrets/set/set_test.go
index 58382c6f..c061b604 100644
--- a/internal/secrets/set/set_test.go
+++ b/internal/secrets/set/set_test.go
@@ -33,7 +33,7 @@ func TestSecretSetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.CreateSecretsJSONBody{dummy}).
@@ -64,7 +64,7 @@ func TestSecretSetCommand(t *testing.T) {
 		require.NoError(t, err)
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.CreateSecretsJSONBody{dummy}).
@@ -145,7 +145,7 @@ func TestSecretSetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.CreateSecretsJSONBody{dummy}).
@@ -170,7 +170,7 @@ func TestSecretSetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Post("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.CreateSecretsJSONBody{dummy}).
diff --git a/internal/secrets/unset/unset_test.go b/internal/secrets/unset/unset_test.go
index 97bff418..9452a0bd 100644
--- a/internal/secrets/unset/unset_test.go
+++ b/internal/secrets/unset/unset_test.go
@@ -29,7 +29,7 @@ func TestSecretUnsetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.DeleteSecretsJSONBody{"my-secret"}).
@@ -94,7 +94,7 @@ func TestSecretUnsetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.DeleteSecretsJSONBody{"my-secret"}).
@@ -119,7 +119,7 @@ func TestSecretUnsetCommand(t *testing.T) {
 		t.Setenv("SUPABASE_ACCESS_TOKEN", string(token))
 		// Flush pending mocks after test execution
 		defer gock.OffAll()
-		gock.New("https://api.supabase.io").
+		gock.New(utils.DefaultApiHost).
 			Delete("/v1/projects/" + project + "/secrets").
 			MatchType("json").
 			JSON(api.DeleteSecretsJSONBody{"my-secret"}).