fix: ensure X-App-Source header survives per-request header overrides

Add onRequest hook to Nova $fetch client so X-App-Source: nova is
always injected even when individual calls pass their own headers
object (which shallow-replaces the createFetch defaults).
This commit is contained in:
MaheshtheDev 2026-05-10 21:20:51 +00:00
parent f8a2b0046e
commit 6e077e1a2f

View file

@ -254,6 +254,11 @@ export const $fetch = createFetch({
baseURL: `${process.env.NEXT_PUBLIC_BACKEND_URL ?? "https://api.supermemory.ai"}/v3`,
credentials: "include",
headers: { "X-App-Source": "nova" },
onRequest: (context: { headers: Headers }) => {
if (!context.headers.has("X-App-Source")) {
context.headers.set("X-App-Source", "nova")
}
},
retry: {
attempts: 3,
delay: 100,