Merge pull request #19 from jonslo/main
PR: Fix Authorization Header for SSE Connections
This commit is contained in:
commit
327b4f7b0e
1 changed files with 19 additions and 1 deletions
|
@ -82,7 +82,25 @@ export async function connectToRemoteServer(
|
|||
): Promise<SSEClientTransport> {
|
||||
log(`[${pid}] Connecting to remote server: ${serverUrl}`)
|
||||
const url = new URL(serverUrl)
|
||||
const transport = new SSEClientTransport(url, { authProvider, requestInit: { headers } })
|
||||
|
||||
// Create transport with eventSourceInit to pass Authorization header if present
|
||||
const eventSourceInit = {
|
||||
fetch: (url: string | URL, init: RequestInit | undefined) => {
|
||||
return fetch(url, {
|
||||
...init,
|
||||
headers: {
|
||||
...init?.headers,
|
||||
...headers,
|
||||
},
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const transport = new SSEClientTransport(url, {
|
||||
authProvider,
|
||||
requestInit: { headers },
|
||||
eventSourceInit,
|
||||
})
|
||||
|
||||
try {
|
||||
await transport.start()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue