xmlhttprequest - How to force Angular to send cookies with Http, but without {withCredentials: true} -


i have situation i'm sending ajax request api requires cookie data has access-control-allow-origin: * header.

when add withcredentials option via http.get(url, {withcredentials: true}) produces following error:

xmlhttprequest cannot load http://my.website.com/api/find. value of 'access-control-allow-origin' header in response must not wildcard '*' when request's credentials mode 'include'. origin 'http://localhost:4200' therefore not allowed access. credentials mode of requests initiated xmlhttprequest controlled withcredentials attribute.

but when don't use withcredentials option, no cookies sent.

how send cookies without using withcredentials option?

if you’re making request cross-origin angular http.get, the requirements in fetch spec (which govern behavior this) necessitate can’t without specifying withcredentials (which sets underlying credentials mode request "include").

the browser prevent working, because that’s spec requirements necessitate.

so if want send credentials in request, need instead is: (re)configure cors settings http://my.website.com/api/find endpoint such value of access-control-allow-origin response header has explicit origin rather "*".

how depends on server system you’re using serve content http://my.website.com/api/find endpoint. in many systems, can setting particular config option such server takes value of origin request header , echoes value of access-control-allow-origin response header sends back.


Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -