Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions templates/cli/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,10 +456,6 @@ export const getCloudEndpointRegion = (endpoint: string): string | null => {
export const isLocalhostHostname = (hostname: string): boolean =>
hostname === "localhost" || hostname === "127.0.0.1" || hostname === "[::1]";

const isCloudEnvironmentHostname = (hostname: string): boolean =>
hostname.endsWith(".cloud.appwrite.io") &&
CLOUD_LOGIN_ENVIRONMENTS.has(hostname.split(".")[0]);

const getCloudConsoleHostname = (hostname: string): string | null => {
if (hostname === "cloud.appwrite.io") {
return hostname;
Expand Down Expand Up @@ -490,8 +486,7 @@ export const isCloudLoginEndpoint = (endpoint: string): boolean => {
try {
const hostname = new URL(endpoint).hostname;
return (
isCloudHostname(hostname) ||
isCloudEnvironmentHostname(hostname) ||
hostname.endsWith(".appwrite.io") ||
(isFlagEnabled("devCloudLogin") && isLocalhostHostname(hostname))
);
} catch (_error) {
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/languages/cli/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,13 @@ async function runAuthChecks() {
assert.equal(isFlagEnabled("devCloudLogin"), false);
assert.equal(isCloudLoginEndpoint("https://cloud.appwrite.io/v1"), true);
assert.equal(isCloudLoginEndpoint("https://stage.cloud.appwrite.io/v1"), true);
assert.equal(isCloudLoginEndpoint("https://new.appwrite.io/v1"), true);
assert.equal(isCloudLoginEndpoint("https://appwrite.io/v1"), false);
assert.equal(isCloudLoginEndpoint("https://notappwrite.io/v1"), false);
Comment thread
ChiragAgg5k marked this conversation as resolved.
assert.equal(
isCloudLoginEndpoint("https://real.appwrite.io.attacker.com/v1"),
false,
);
assert.equal(isCloudLoginEndpoint("http://localhost/v1"), false);
} finally {
if (prev === undefined) delete process.env.APPWRITE_CLI_DEV_CLOUD_LOGIN;
Expand Down
Loading