3

for sending cookie to server I must use { withCredentials: true } in options parameter,But When I use

    this.http.get(this.accountUrl + 'ExternalLoginConfirmation', { 
    withCredentials: true })

I get the following error :

    Response to preflight request doesn't pass access control check: The 
    value 
    of the 'Access-Control-Allow-Origin' header in the response must not be 
    the 
    wildcard '*' when the request's credentials mode is 'include'. Origin 
    'http://localhost:4202' is therefore not allowed access. The credentials 
    mode of requests initiated by the XMLHttpRequest is controlled by the 
    withCredentials attribute.

Odd thing : There isn't any error when I call this url by browser

Could you help me?

Ali Abbaszade
  • 151
  • 1
  • 2
  • 16

1 Answers1

0

This is a CORS error , Try adding Cors chrome extension browser and add your url in it this error will go away. Or for permanent resolution Refer to https://stackoverflow.com/a/24446980/4808975

Harshit Chawla
  • 113
  • 1
  • 9
  • 2
    Thanks! It works with `builder.AllowAnyOrigin() .AllowAnyMethod().AllowAnyHeader().AllowCredentials();` in server side – Ali Abbaszade Feb 17 '18 at 09:46