I set up a ServiceStack application running on port 5001

Using the typescript client for ServiceStack (using typescript-ref), I generated the dtos

I need to intercept the responses because sometimes my server will redirect the client to another page. But I cannot do it with standard XHR redirects, I need to do this with an HTTP interceptor (similar to angular's)

I set up an angular JsonServiceClient

import { Injectable } from '@angular/core';
import { JsonServiceClient } from '@servicestack/client';
import { Router } from '@angular/router';

  providedIn: 'root',
export class ServiceClient extends JsonServiceClient {
  constructor(router: Router) {
    this.responseFilter = res => {
      const navigateTo = res.headers.get('X-Navigate-To');
      if (!navigateTo) {

// client.responseFilter is triggered successfully, but the Response.headers does not contain the headers sent by the service. Only `content-type: application-json`

In my service, I add a request header

 // ...
 return new HttpResponse(HttpStatusCode.NoContent){
    Headers = {{"X-Navigate-To", "/home/whathever"}}
 // ...

I can successfully see the header being returned on the browser console

When I inspect the Fetch Response headers, I only see Content-Type as headers, and status code is 200

How can I add a ResponseFilter that will capture the actual GET / POST / PUT / DELETE requests ?

1 Answers

Ludovic C On

I needed to expose the "X-Navigate-To" header in the cors feature

            new CorsFeature
                allowCredentials: true,
                allowOriginWhitelist: new List<string> {"https://localhost:4200"},
                allowedHeaders: "Content-Type,Authorization",
                exposeHeaders: "X-Navigate-To"