V
V
Vladimir Mirka2017-11-20 14:07:08
JavaScript
Vladimir Mirka, 2017-11-20 14:07:08

Angular 2 - how to send an OPTIONS request with the right headers?

Hello. The situation is approximately the following - the server is waiting for a GET request with the Authorization header. However, the first thing is an OPTIONS request is sent, the server hands it a 403 error (as planned) and kicks it back.
Through postman everything works fine. Question. How to make sure that the OPTIONS request contains the necessary header? And is it even possible to do this?
What I'm trying to do in Angular:

const headers: Headers = new Headers({
  'Content-Type': 'application/json',
  'Authorization': data
});

const options: RequestOptions = new RequestOptions({
  withCredentials: true,
  headers: headers
});

return this.http.get('http://localhost:4300/api/current-data', options)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RubaXa, 2017-11-20
@flexaccess

No way.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question