Skip to content

Commit a51acf9

Browse files
committed
fix: deletion requests sent to the manager region.
1 parent d549b95 commit a51acf9

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

src/routes/(console)/project-[region]-[project]/settings/deleteProject.svelte

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,38 @@
11
<script lang="ts">
2-
import { goto } from '$app/navigation';
32
import { base } from '$app/paths';
4-
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
3+
import { isCloud } from '$lib/system';
4+
import { goto } from '$app/navigation';
5+
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
56
import { BoxAvatar, CardGrid, Heading, Modal } from '$lib/components';
67
import { Button, FormList, InputText } from '$lib/elements/forms';
78
import { toLocaleDateTime } from '$lib/helpers/date';
89
import { addNotification } from '$lib/stores/notifications';
9-
import { sdk } from '$lib/stores/sdk';
10-
import { isCloud } from '$lib/system';
10+
import { getApiEndpoint } from '$lib/stores/sdk';
1111
import { project, projectRegion } from '../store';
12+
import { Client as TempClient, Projects as TempProjects } from '@appwrite.io/console';
1213
1314
let showDelete = false;
1415
let name: string = null;
1516
17+
/**
18+
* This ensures the underlying client use a region-aware endpoint
19+
* to correctly route project deletion requests to the appropriate regional pool.
20+
*
21+
* The console project itself isn't tied to a region, so its client doesn’t
22+
* include one. Without this, deletion requests would default to the manager region.
23+
*/
24+
const temporaryProjects = (region: string) => {
25+
const tempClient = new TempClient()
26+
.setMode('admin')
27+
.setProject('console')
28+
.setEndpoint(getApiEndpoint(region));
29+
30+
return new TempProjects(tempClient);
31+
};
32+
1633
const handleDelete = async () => {
1734
try {
18-
await sdk.forConsole.projects.delete($project.$id);
35+
await temporaryProjects($project.region).delete($project.$id);
1936
showDelete = false;
2037
addNotification({
2138
type: 'success',

0 commit comments

Comments
 (0)