question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

seeing 2 requests to server, one without and one with the Authorization header

See original GitHub issue

Angular 4.3.3 build --prod using ahead of time compilation

When a request is made from the client via:

this.authHttp.get(url, options)
    .subscribe(
      data => console.log("res data:", data),
      error => console.log("error:", error),
      () => console.log('complete')
);

I am seeing 2 requests occur when there should only be one, correct?

The first with the initiator being the pollyfills JS chunk which does NOT include the Authorization header.

That request is immediately followed by a second request with the initiator labeled Other. This request DOES include the Authorization header correctly.

Is this a bug?

Does anyone know how to prevent the first request from firing?

Any help greatly appreciated.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
chenkiecommented, Aug 4, 2017

Thanks for putting the link here @escardin.

@gitdisrupt the OPTIONS call happens to ask the server what kinds of requests it supports before making the actual intended request. It’s a browser thing rather than an Angular/angular2-jwt thing.

1reaction
escardincommented, Aug 4, 2017

See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

You won’t see double, only the initial request for each url should see it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTTPClient sends out two requests when using Basic Auth?
I see in Charles Proxy that there are two requests being sent. One without the Authorization: Basic ... header and one with it....
Read more >
Authorization - HTTP - MDN Web Docs - Mozilla
The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a...
Read more >
Using the Authorization Header (AWS Signature Version 4)
Using the HTTP Authorization header is the most common method of providing authentication information. Except for POST requests and requests that are signed...
Read more >
HTTP/1.1: Header Field Definitions
Indicates that all or part of the response message is intended for a single user and MUST NOT be cached by a shared...
Read more >
Why authorization header not included in request ? - Auth0
So, I have the following two endpoints in my flask app: A public endpoint which requires no authentication process: @APP.route("/api/public") @ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found