Skip to content

socksjs-node caches old information, setting HTTP Headers failsΒ #17938

@linocatucci

Description

@linocatucci

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • [ x] serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • xi18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

no

Yes, the previous version in which this bug was not present was: I don't know

Description

I have set up a HttpClient get call and I am setting a http headers. But the wrong http headers information is set (or overwritten) by the information which is set in the sockjs-node.

My get call in the service looks like this:

  getUsers(): Observable<IUser[]> {
    const url = `${this.backendApiUrl}/api/users`;
    const token = this.authService.getTokenFromLocalStorage();
    console.log('####-user-service', token);
    return this.http.get<IUser[]>(url, {
      headers: new HttpHeaders().set('authtoken', token),
    });
  }

The token property from local storage is the correct token but the sockjs-node call has a different token and that is applied to my HttpHeader.

πŸ”¬ Minimal Reproduction

If you have in the sockjs-node info call the same request header set, this will be transferred to the set Headers in backend call.

πŸ”₯ Exception or Error

not authorized because wrong auth token is provided

🌍 Your Environment


Angular CLI: 9.0.2
Node: 12.16.2
OS: darwin x64

Angular: 9.0.1
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.2
@angular-devkit/build-angular     0.900.2
@angular-devkit/build-optimizer   0.900.2
@angular-devkit/build-webpack     0.900.2
@angular-devkit/core              9.0.2
@angular-devkit/schematics        9.0.2
@angular/cdk                      9.2.4
@angular/cli                      9.0.2
@angular/fire                     6.0.0
@angular/flex-layout              9.0.0-beta.31
@angular/material                 9.2.4
@ngtools/webpack                  9.0.2
@schematics/angular               9.0.2
@schematics/update                0.900.2
rxjs                              6.5.4
typescript                        3.7.5
webpack                           4.41.2

Anything else relevant?
no

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions