Skip to content

Commit 073396c

Browse files
[Nitro CLI] Always set path to /graphql in custom Cloud Url (#9109)
1 parent 934d445 commit 073396c

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

src/Nitro/CommandLine/src/CommandLine/Extensions/ApiClientCommandLineBuilderExtensions.cs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,23 @@ private static IHttpClientFactory ConfigureClientFactory(IServiceProvider sp)
4343
}
4444
else if (!string.IsNullOrWhiteSpace(cloudUrl))
4545
{
46-
if (Uri.TryCreate(cloudUrl, Absolute, out var uri))
47-
{
48-
client.BaseAddress = uri;
49-
}
50-
else if (Uri.TryCreate($"https://{cloudUrl}/graphql", Absolute, out uri))
51-
{
52-
client.BaseAddress = uri;
53-
}
54-
else
46+
if (!Uri.TryCreate(cloudUrl, Absolute, out var uri)
47+
&& !Uri.TryCreate($"https://{cloudUrl}", Absolute, out uri))
5548
{
5649
throw new ExitException($"Could not parse cloud URL: {cloudUrl}");
5750
}
51+
52+
// Ensure that Uri is always <host>/graphql
53+
var uriBuilder = new UriBuilder(uri)
54+
{
55+
Path = "/graphql",
56+
Query = string.Empty,
57+
Fragment = string.Empty,
58+
UserName = string.Empty,
59+
Password = string.Empty
60+
};
61+
62+
client.BaseAddress = uriBuilder.Uri;
5863
}
5964
else
6065
{

0 commit comments

Comments
 (0)