Skip to content

Commit 6fbf497

Browse files
authored
Merge pull request #282 from buggregator/fix/attachment-api-path
fix: update attachment URLs for new server route layout
2 parents 9373e75 + e554800 commit 6fbf497

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/shared/lib/io/use-attachments.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ export const useAttachments: TUseAttachments = (module: EventModule = 'smtp') =>
1515

1616
const headers = {"X-Auth-Token": token.value }
1717

18-
const calcDownloadLink = (id: EventId, attachmentId?: string): string => `${REST_API_URL}/api/${module}/${id}/attachments${attachmentId ? `/${attachmentId}` : ''}`
18+
// The server namespaces attachment endpoints under `/api/{module}/attachments/...`
19+
// (literal `attachments` segment first) to avoid colliding with module routes
20+
// like `/api/smtp/message/{uuid}/raw`. See server: internal/server/http/attachments.go.
21+
const calcDownloadLink = (id: EventId, attachmentId?: string): string =>
22+
`${REST_API_URL}/api/${module}/attachments/${id}${attachmentId ? `/${attachmentId}` : ''}`
1923

2024
const getAttachments = (id: EventId) => fetch(calcDownloadLink(id), { headers })
2125
.then((response) => response.json())

0 commit comments

Comments
 (0)