Typescript JsonServiceClient custom header

I would like to add one custom header to all the outgoing POST calls sent by the typescript JsonServiceClient.

I’m using the requetFilter, this is the code

  constructor() {
    this.sseClient = new ServerEventsClient(this.endPoint, this.channels, {
      onException: this.onException
    });

    this.sseClient.serviceClient.requestFilter = AppServerEventsService.filtroRichieste;
  }

  static filtroRichieste(req: IRequestInit)
  {
    let headers = new Headers(req.headers);
    headers.set('X-Tag', 'my-tag');

    req.headers = headers;
  }

it works only for the /json/reply/UpdateEventSubscriber POST not for the event-heartbeat calls and I don’t why.
Any suggestions?

I’m using

"@servicestack/client": "^1.0.31",

Thanks

That’s not supported, the request filter is only applied to JsonServiceClient API Requests, not EventSource or heartbeat fetch requests. EventSource only accepts a URL, I don’t see any API that lets you send custom headers. You can take a local copy of the ServerEventsClient and customize the fetch heartbeat request but you wouldn’t be able to add a custom header in the EventStream request, you’ll likely need to use a custom URL and QueryParam instead.