简体   繁体   中英

Options request has created while sending GET request with headers - Angular7

在此处输入图片说明

When i send GET request along with headers(see username in the image),a Options request triggered by Angular instead of sending GET request that cause my request fail but it works fine without headers. I have highlihted the Request method as you can see it is Options but it should be GET.

this._http
      .get(url,{ headers: {  'userName':'john' }} )

From your image it appears the server is only returning allow-headers for Content-Type & Accept.

Try adding 'username' to this list.

Note the OPTIONS request occurs as a result of CORS (and not Angular specifically).

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM