Skip to content

Commit 9c4daab

Browse files
committed
chore: fetch endpoint
1 parent fee141d commit 9c4daab

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

templates/cli/lib/questions.js.twig

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,17 +219,17 @@ const questionsInitProject = [
219219
type: "list",
220220
name: "region",
221221
message: "Select your Appwrite Cloud region",
222-
choices: [
223-
{ name: "Frankfurt (fra)", value: "fra" },
224-
{ name: "New York (nyc)", value: "nyc" },
225-
{ name: "Sydney (syd)", value: "syd" }
226-
],
227-
default: () => {
228-
const endpoint = globalConfig.getEndpoint() || "https://cloud.appwrite.io/v1";
229-
if (endpoint.includes('fra')) return 'fra';
230-
if (endpoint.includes('nyc')) return 'nyc';
231-
if (endpoint.includes('syd')) return 'syd';
232-
return '';
222+
choices: async () => {
223+
let client = await sdkForConsole(true);
224+
let response = await client.call("GET", "/console/regions");
225+
let regions = response.regions || [];
226+
if (!regions.length) {
227+
throw new Error("No regions found. Please check your network or Appwrite Cloud availability.");
228+
}
229+
return regions.filter(region => !region.disabled).map(region => ({
230+
name: `${region.name} (${region.$id})`,
231+
value: region.$id
232+
}));
233233
},
234234
when: () => {
235235
try {

0 commit comments

Comments
 (0)