I have spent a full day at it trying to find a solution for this and have tried almost all top voted answers in these SOF posts here, here and here.
So here is the situation:
- GET & POST requests are working fine
- PUT requests are throwing 403 as shown below
We don't have any DELETE requests at the moment to test if that is also effected or not
We have two repositories (1) Backend API - using .Net Core 3.1 and (2) Vue3/typescript/Axios client, being deployed to two domains, api to my-api.blahblah.com
and web client to www.blahblah.com
. Maybe relevant or not but it's on a VPS running Windows Server 2019 and IIS10. Reason for having two separate, is to have them independently deployable, separate pipelines are setup and working fine.
The CORS setup in startup.cs looks like this, I have tried different variation of these based on the answers from the SOF links above:
services.AddCors(options =>
{
options.AddPolicy("CorsPolicy", policy =>
{
policy
.AllowAnyOrigin()
.AllowAnyHeader()
.AllowAnyMethod();
});
});
...
app.UseCors("CorsPolicy");
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
The web.config file of the web client looks like this:
and the web.config of the api domain is this:
Hopefully I have added enough information but if i missed something please let me know.
I have a feeling I am missing something very trivial to get the PUT requests to work but maybe my bad day.
Thanks in advance.
EDIT 1: Additional information
- Requests through POSTMAN are also failing with 403.
- The apps work fine on local IIS (development machine).
EDIT 2:
- DELETE is not working as well, throwing same CORS error
- It is not auth issues as I placed [AllowAnnonymous] on several PUT and DELETE endpoints in API and redeployed it but still getting same errors as before
- Some last entries from IIS after allowing anony access to PUT endpoint below (notice 403 on PUT):
2021-12-15 19:29:37 SERVER_IP_REDACTED GET /api/employeeAddress PageIndex=0&PageSize=10 443 - MY_IP_REDACTED HTTP/2 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/xx.xx.xx.xx+Safari/537.36 https://WEBSITE_NAME_REDACTED/ MY_API 200 0 0 718 1558 364
2021-12-15 19:29:49 SERVER_IP_REDACTED OPTIONS /api/employeeAddress/10 - 443 - MY_IP_REDACTED HTTP/2 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/xx.xx.xx.xx+Safari/537.36 https://WEBSITE_NAME_REDACTED/ MY_API 204 0 0 305 623 70
2021-12-15 19:29:49 SERVER_IP_REDACTED GET /api/employeeAddress/10 - 443 - MY_IP_REDACTED HTTP/2 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/xx.xx.xx.xx+Safari/537.36 https://WEBSITE_NAME_REDACTED/ MY_API 200 0 0 393 1537 95
2021-12-15 19:29:55 SERVER_IP_REDACTED OPTIONS /api/employeeAddress/10 - 443 - MY_IP_REDACTED HTTP/2 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/xx.xx.xx.xx+Safari/537.36 https://WEBSITE_NAME_REDACTED/ MY_API 204 0 0 318 636 84
2021-12-15 19:29:55 SERVER_IP_REDACTED PUT /api/employeeAddress/10 - 443 - MY_IP_REDACTED HTTP/2 Mozilla/5.0+(Windows+NT+10.0;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/xx.xx.xx.xx+Safari/537.36 https://WEBSITE_NAME_REDACTED/ MY_API 403 0 0 1452 1712 74
Edit 3 EmployeeAddressController screenshot as requested: