From 026cb1217d07778a30327b714eb707329ee5cbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20K=C3=B6nig?= Date: Wed, 15 Jan 2025 13:42:17 +0100 Subject: [PATCH] simplfy eventsource reconnect by getting token on fetch --- src/modules/sse/SseModule.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/modules/sse/SseModule.ts b/src/modules/sse/SseModule.ts index abb4137d..0ae9d1cc 100644 --- a/src/modules/sse/SseModule.ts +++ b/src/modules/sse/SseModule.ts @@ -56,15 +56,17 @@ export default class SseModule extends ConnectorRuntimeModule - fetch(url, { + fetch: async (url, options) => { + const token = await this.runtime.getBackboneAuthenticationToken(); + + return await fetch(url, { ...options, dispatcher: proxy ? new ProxyAgent({ ...baseOptions, uri: proxy }) : new Agent(baseOptions), headers: { ...options?.headers, authorization: `Bearer ${token}` } - }) + }); + } }); this.eventSource = eventSource;