Skip to content

Commit 25d433c

Browse files
ldanilekConvex, Inc.
authored and
Convex, Inc.
committed
use big-brain to get url from CONVEX_DEPLOY_KEY (#34040)
preparation for canonical custom domains instead of generating urls from deploy keys, use the `/url_for_key` endpoint when deploying with a CONVEX_DEPLOY_KEY to find the url. This allows us to switch from .convex.cloud to a custom domain in a future change. With this change, the CLI should never try to calculate the url itself, and it shouldn't care what the url looks like. Therefore we should be able to change big-brain apis to return new urls, and the CLI should use them everywhere. Now that we're using `/url_for_key` in more places, update its docstring. Note it's unusual as an endpoint because it doesn't check authorization with the normal ExtractIdentity, but as long as we validate the deploy key and only return the url, there should be no authz concerns. GitOrigin-RevId: 453c4444c6285ad2192d25abe948e2a54d13db0c
1 parent 1478c1d commit 25d433c

File tree

1 file changed

+10
-21
lines changed
  • npm-packages/convex/src/cli/lib

1 file changed

+10
-21
lines changed

npm-packages/convex/src/cli/lib/api.ts

+10-21
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,16 @@ async function fetchDeploymentCredentialsWithinCurrentProjectInner(
397397
ctx,
398398
configuredAdminKey!,
399399
);
400-
let url = await deriveUrlFromAdminKey(ctx, configuredAdminKey!);
401-
// We cannot derive the deployment URL from the deploy key
402-
// when running against local big brain, so use the name to get the URL.
403-
if (process.env.CONVEX_PROVISION_HOST !== undefined) {
404-
url = await bigBrainAPI({
405-
ctx,
406-
method: "POST",
407-
url: "deployment/url_for_key",
408-
data: {
409-
deployKey: configuredAdminKey,
410-
},
411-
});
412-
}
400+
// We cannot derive the deployment URL from the deploy key, because it
401+
// might be a custom domain. Ask big brain for the URL.
402+
const url = await bigBrainAPI({
403+
ctx,
404+
method: "POST",
405+
url: "deployment/url_for_key",
406+
data: {
407+
deployKey: configuredAdminKey,
408+
},
409+
});
413410
const deploymentType = deploymentTypeFromAdminKey(configuredAdminKey!);
414411
return {
415412
adminKey: configuredAdminKey,
@@ -617,11 +614,3 @@ async function fetchExistingDevDeploymentCredentialsOrCrash(
617614
}
618615
return credentialsAsDevCredentials(credentials);
619616
}
620-
621-
// This returns the the url of the deployment from an admin key in the format
622-
// "tall-forest-1234|1a2b35123541"
623-
// or "prod:tall-forest-1234|1a2b35123541"
624-
async function deriveUrlFromAdminKey(ctx: Context, adminKey: string) {
625-
const deploymentName = await deploymentNameFromAdminKeyOrCrash(ctx, adminKey);
626-
return `https://${deploymentName}.convex.cloud`;
627-
}

0 commit comments

Comments
 (0)