Ionic + Cordova app not sending JSESSIONID cookie

Discussão em 'Angular' iniciado por Pablo, Abril 23, 2025.

  1. Pablo

    Pablo Guest

    I'm working on a legacy app at the company I work for. This app is built with Ionic + Cordova + Angular. Thing is that the app isn't sending the JSESSIONID sent by one of the backend services we're using.

    We have already implemented in the past an HttpInterceptor that injects withCredentials: true, along with other params the backend requires.

    Now this works on Android and Web, but on iOS for some reason isn't working on our Staging server.

    Here's our interceptor:

    @Injectable({
    providedIn: 'root',
    })
    export class OurHttpAuthHandler extends HttpHandler {
    /* ATTRIBUTES */

    private authToken$ = of('asd') // some auth token the BE requests. Replaced the actual code just for privacy reasons.

    /* LIFECYCLE */

    public constructor(private httpHandler: HttpHandler, private auth: AuthService) {
    super();
    }

    /* METHODS */

    /**
    * Injects the authentication header into all requests.
    * @param request The incoming request to handle.
    * @returns The response to the request.
    */
    public handle(request: HttpRequest<any>): Observable<HttpEvent<any>> {
    return this.authToken$.pipe(
    take(1),
    switchMap((authToken) => {
    const modifiedRequest = request.clone({
    withCredentials: true,
    setHeaders: {
    Accept: 'application/json',
    Authorization: `Basic ${authToken}`,
    'Disable-Payload-Encoding': 'true',
    },
    });
    return this.httpHandler.handle(modifiedRequest);
    }),
    );
    }
    }


    When I call the POST endpoint in charge of creating a new session, it returns the JSESSIONID cookie for the session. But the subsequent requests seem to ignore it and the withCredentials.

    Any thougths?

    Continue reading...

Compartilhe esta Página