Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 58b8ba7

Browse files
authored
fix: update URLs (#933)
1 parent b62cfbd commit 58b8ba7

11 files changed

Lines changed: 61 additions & 37 deletions

File tree

clienv/clienv.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ type CliEnv struct {
2222
stdout io.Writer
2323
stderr io.Writer
2424
Path *PathStructure
25-
domain string
25+
authURL string
26+
graphqlURL string
2627
branch string
2728
nhclient *nhostclient.Client
2829
nhpublicclient *nhostclient.Client
@@ -34,7 +35,8 @@ func New(
3435
stdout io.Writer,
3536
stderr io.Writer,
3637
path *PathStructure,
37-
domain string,
38+
authURL string,
39+
graphqlURL string,
3840
branch string,
3941
projectName string,
4042
localSubdomain string,
@@ -43,7 +45,8 @@ func New(
4345
stdout: stdout,
4446
stderr: stderr,
4547
Path: path,
46-
domain: domain,
48+
authURL: authURL,
49+
graphqlURL: graphqlURL,
4750
branch: branch,
4851
nhclient: nil,
4952
nhpublicclient: nil,
@@ -67,7 +70,8 @@ func FromCLI(cCtx *cli.Context) *CliEnv {
6770
cCtx.String(flagDataFolder),
6871
cCtx.String(flagNhostFolder),
6972
),
70-
domain: cCtx.String(flagDomain),
73+
authURL: cCtx.String(flagAuthURL),
74+
graphqlURL: cCtx.String(flagGraphqlURL),
7175
branch: cCtx.String(flagBranch),
7276
projectName: sanitizeName(cCtx.String(flagProjectName)),
7377
nhclient: nil,
@@ -84,8 +88,12 @@ func (ce *CliEnv) LocalSubdomain() string {
8488
return ce.localSubdomain
8589
}
8690

87-
func (ce *CliEnv) Domain() string {
88-
return ce.domain
91+
func (ce *CliEnv) AuthURL() string {
92+
return ce.authURL
93+
}
94+
95+
func (ce *CliEnv) GraphqlURL() string {
96+
return ce.graphqlURL
8997
}
9098

9199
func (ce *CliEnv) Branch() string {
@@ -99,7 +107,8 @@ func (ce *CliEnv) GetNhostClient(ctx context.Context) (*nhostclient.Client, erro
99107
return nil, fmt.Errorf("failed to load session: %w", err)
100108
}
101109
ce.nhclient = nhostclient.New(
102-
ce.domain,
110+
ce.authURL,
111+
ce.graphqlURL,
103112
graphql.WithAccessToken(session.Session.AccessToken),
104113
)
105114
}
@@ -108,7 +117,7 @@ func (ce *CliEnv) GetNhostClient(ctx context.Context) (*nhostclient.Client, erro
108117

109118
func (ce *CliEnv) GetNhostPublicClient() (*nhostclient.Client, error) {
110119
if ce.nhpublicclient == nil {
111-
ce.nhpublicclient = nhostclient.New(ce.domain)
120+
ce.nhpublicclient = nhostclient.New(ce.authURL, ce.graphqlURL)
112121
}
113122
return ce.nhpublicclient, nil
114123
}

clienv/flags.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ import (
1010
)
1111

1212
const (
13-
flagDomain = "domain"
13+
flagAuthURL = "auth-url"
14+
flagGraphqlURL = "graphql-url"
1415
flagBranch = "branch"
1516
flagProjectName = "project-name"
1617
flagRootFolder = "root-folder"
@@ -52,10 +53,17 @@ func Flags() ([]cli.Flag, error) { //nolint:funlen
5253

5354
return []cli.Flag{
5455
&cli.StringFlag{ //nolint:exhaustruct
55-
Name: flagDomain,
56-
Usage: "Nhost domain",
57-
EnvVars: []string{"NHOST_DOMAIN"},
58-
Value: "nhost.run",
56+
Name: flagAuthURL,
57+
Usage: "Nhost auth URL",
58+
EnvVars: []string{"NHOST_CLI_AUTH_URL"},
59+
Value: "https://otsispdzcwxyqzbfntmj.auth.eu-central-1.nhost.run/v1",
60+
Hidden: true,
61+
},
62+
&cli.StringFlag{ //nolint:exhaustruct
63+
Name: flagGraphqlURL,
64+
Usage: "Nhost GraphQL URL",
65+
EnvVars: []string{"NHOST_CLI_GRAPHQL_URL"},
66+
Value: "https://otsispdzcwxyqzbfntmj.graphql.eu-central-1.nhost.run/v1",
5967
Hidden: true,
6068
},
6169
&cli.StringFlag{ //nolint:exhaustruct

clienv/wf_login.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (ce *CliEnv) loginEmailPassword(
118118
email string,
119119
password string,
120120
) (credentials.Credentials, error) {
121-
cl := nhostclient.New(ce.Domain())
121+
cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL())
122122
var err error
123123
if email == "" {
124124
ce.PromptMessage("email: ")
@@ -166,10 +166,7 @@ func (ce *CliEnv) loginGithub(ctx context.Context) (credentials.Credentials, err
166166
}
167167
}()
168168

169-
signinPage := fmt.Sprintf(
170-
"https://%s/v1/auth/signin/provider/github/?redirectTo=https://local.dashboard.nhost.run:8099/signin",
171-
ce.Domain(),
172-
)
169+
signinPage := ce.AuthURL() + "/signin/provider/github/?redirectTo=https://local.dashboard.nhost.run:8099/signin"
173170
ce.Infoln("Opening browser to sign-in")
174171
if err := openBrowser(signinPage); err != nil {
175172
return credentials.Credentials{}, err
@@ -178,7 +175,7 @@ func (ce *CliEnv) loginGithub(ctx context.Context) (credentials.Credentials, err
178175

179176
refreshTokenValue := <-refreshToken
180177

181-
cl := nhostclient.New(ce.Domain())
178+
cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL())
182179
refreshTokenResp, err := cl.RefreshToken(ctx, refreshTokenValue)
183180
if err != nil {
184181
return credentials.Credentials{}, fmt.Errorf("failed to get access token: %w", err)
@@ -228,7 +225,7 @@ func (ce *CliEnv) verifyEmail(
228225
) error {
229226
ce.Infoln("Your email address is not verified")
230227

231-
cl := nhostclient.New(ce.Domain())
228+
cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL())
232229
if err := cl.VerifyEmail(ctx, email); err != nil {
233230
return fmt.Errorf("failed to send verification email: %w", err)
234231
}

clienv/wf_session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func (ce *CliEnv) LoadSession(
2020
}
2121
}
2222

23-
cl := nhostclient.New(ce.Domain())
23+
cl := nhostclient.New(ce.AuthURL(), ce.GraphqlURL())
2424
session, err := cl.LoginPAT(ctx, creds.PersonalAccessToken)
2525
if err != nil {
2626
return credentials.Session{}, fmt.Errorf("failed to login: %w", err)

cmd/config/validate_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ func TestValidate(t *testing.T) {
250250
filepath.Join("testdata", "validate", tc.path, ".nhost", "data"),
251251
filepath.Join("testdata", "validate", tc.path, "nhost"),
252252
),
253-
"fakedomain",
253+
"fakeauthurl",
254+
"fakegraphqlurl",
254255
"fakebranch",
255256
"",
256257
"local",

cmd/dockercredentials/get.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import (
1212
)
1313

1414
const (
15-
flagDomain = "domain"
15+
flagAuthURL = "auth-url"
16+
flagGraphqlURL = "graphql-url"
1617
)
1718

1819
func CommandGet() *cli.Command {
@@ -23,23 +24,31 @@ func CommandGet() *cli.Command {
2324
Hidden: true,
2425
Flags: []cli.Flag{
2526
&cli.StringFlag{ //nolint:exhaustruct
26-
Name: flagDomain,
27-
Usage: "Nhost domain",
28-
EnvVars: []string{"NHOST_DOMAIN"},
29-
Value: "nhost.run",
27+
Name: flagAuthURL,
28+
Usage: "Nhost auth URL",
29+
EnvVars: []string{"NHOST_CLI_AUTH_URL"},
30+
Value: "https://otsispdzcwxyqzbfntmj.auth.eu-central-1.nhost.run/v1",
31+
Hidden: true,
32+
},
33+
&cli.StringFlag{ //nolint:exhaustruct
34+
Name: flagGraphqlURL,
35+
Usage: "Nhost GraphQL URL",
36+
EnvVars: []string{"NHOST_CLI_GRAPHQL_URL"},
37+
Value: "https://otsispdzcwxyqzbfntmj.graphql.eu-central-1.nhost.run/v1",
3038
Hidden: true,
3139
},
3240
},
3341
Action: actionGet,
3442
}
3543
}
3644

37-
func getToken(ctx context.Context, domain string) (string, error) {
45+
func getToken(ctx context.Context, authURL, graphqlURL string) (string, error) {
3846
ce := clienv.New(
3947
os.Stdout,
4048
os.Stderr,
4149
&clienv.PathStructure{},
42-
domain,
50+
authURL,
51+
graphqlURL,
4352
"unneeded",
4453
"unneeded",
4554
"unneeded",
@@ -65,7 +74,7 @@ func actionGet(c *cli.Context) error {
6574
for scanner.Scan() {
6675
input += scanner.Text()
6776
}
68-
token, err := getToken(c.Context, c.String(flagDomain))
77+
token, err := getToken(c.Context, c.String(flagAuthURL), c.String(flagGraphqlURL))
6978
if err != nil {
7079
return err
7180
}

cmd/project/init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ func InitRemote(
187187
}
188188

189189
hasuraEndpoint := fmt.Sprintf(
190-
"https://%s.hasura.%s.%s", proj.Subdomain, proj.Region.Name, ce.Domain(),
190+
"https://%s.hasura.%s.nhost.run", proj.Subdomain, proj.Region.Name,
191191
)
192192

193193
if err := deploy(

get_access_token.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ output=`curl \
55
--fail -s \
66
-H "Content-Type: application/json" \
77
-d "{\"personalAccessToken\":\"$NHOST_PAT\"}" \
8-
https://staging.nhost.run/v1/auth/signin/pat`
8+
https://mytpiiwxeyrvlqrxuknp.auth.eu-central-1.nhost.run/v1/signin/pat`
99

1010
if [ $? -ne 0 ]; then
1111
echo "Error: Failed to get access token"

gqlgenc.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ models:
2525
- github.com/99designs/gqlgen/graphql.Uint32
2626

2727
endpoint:
28-
url: https://staging.nhost.run/v1/graphql
28+
url: https://mytpiiwxeyrvlqrxuknp.graphql.eu-central-1.nhost.run/v1
2929
headers:
3030
Authorization: Bearer $NHOST_ACCESS_TOKEN # # support environment variables
3131

nhostclient/graphql/models_gen.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)