I'm working on an Angular site with:
• .Net Framework server on localhost/test
• client on localhost:4200
I've got cookie authentication working, and my GET requests are working fine.
this.httpClient.get<Test>('dummyUrl', { withCredentials: true });
In my web.config for the server I have the following.
<add name="Access-Control-Allow-Credentials" value="true"/>
<add name="Access-Control-Allow-Origin" value="http://localhost:4200" />
<add name="Access-Control-Allow-Methods" value="*" />
Given this setup I'd expect the same to work for PUT and POST requests.
this.httpClient.put('dummyUrl', this.payload, { withCredentials: true });
I get a 401 Unauthorized from this.
My Investigation
The request method I see made is OPTIONS, which tells me that this is failing on the pre-flight, and that this issue relates to CORS rather than Angular. I've been unable to work out what I'm missing.
I'd be grateful for any guidance.