From d5c08a28d60eead1c07242b8e5faa9e9767b4dd2 Mon Sep 17 00:00:00 2001 From: Francesco Giovannini Date: Tue, 12 May 2026 17:12:10 +0200 Subject: [PATCH] fix(sqs): forward localstack headers in receiveMessagesPoll receiveMessagesPoll used a raw fetch without x-localstack-endpoint/x-localstack-region headers, so the backend fell back to the default region and returned 404 "Queue not found" for queues created in other regions. Export getConfigHeaders from api-client and apply it to the polling fetch. --- packages/frontend/src/api/sqs.ts | 7 +++++-- packages/frontend/src/lib/api-client.ts | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/frontend/src/api/sqs.ts b/packages/frontend/src/api/sqs.ts index e1d29ed..83ee682 100644 --- a/packages/frontend/src/api/sqs.ts +++ b/packages/frontend/src/api/sqs.ts @@ -1,5 +1,5 @@ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; -import { apiClient } from "@/lib/api-client"; +import { apiClient, getConfigHeaders } from "@/lib/api-client"; // --- Interfaces --- @@ -233,7 +233,10 @@ export async function receiveMessagesPoll( const url = new URL(`/api/sqs/${queueName}/messages`, window.location.origin); url.searchParams.set("maxMessages", String(maxMessages)); url.searchParams.set("waitTimeSeconds", String(waitTimeSeconds)); - const response = await fetch(url.toString(), { signal }); + const response = await fetch(url.toString(), { + signal, + headers: { ...getConfigHeaders() }, + }); if (!response.ok) { const body = await response .json() diff --git a/packages/frontend/src/lib/api-client.ts b/packages/frontend/src/lib/api-client.ts index 08a3728..987aeeb 100644 --- a/packages/frontend/src/lib/api-client.ts +++ b/packages/frontend/src/lib/api-client.ts @@ -2,7 +2,7 @@ import { useConfigStore } from "@/stores/config"; const BASE_URL = "/api"; -function getConfigHeaders(): Record { +export function getConfigHeaders(): Record { const { endpoint, region } = useConfigStore.getState(); return { "x-localstack-endpoint": endpoint,