How do I add a json web token to each header?

后端 未结 3 680
日久生厌
日久生厌 2021-02-09 02:39

So I am trying to use JSON web tokens for authentication and am struggling trying to figure out how to attach them to a header and send them on a request.

I was trying t

3条回答
  •  庸人自扰
    2021-02-09 02:44

    I see several options to set an header transparently for each request:

    • Implement an HttpClient service to use instead of the default Http one.
    • Provide your own implementation of the RequestOptions class
    • Override the Http class it self

    This way you could set your header in one place and this would impact aok your HTTP calls.

    See the following questions:

    • How to set default HTTP header in Angular2?
    • Angular2 - set headers for every request
    • How do you set global custom headers in Angular2?

提交回复
热议问题