Failed to load resource: the server responded with a status of 401 (Unauthorized) #1109

Open
opened 2019-09-12 20:51:57 +00:00 by thopah · 3 comments
thopah commented 2019-09-12 20:51:57 +00:00 (Migrated from github.com)

hi, i am trying to implement the server API (dotnet core 2.2)with Active Directory authentication. And on my client side, i am using Angular 8 with ng2-file-upload. I keep getting an 401 401 Unauthorized with request method: OPTIONS. I already setup the CORS on the server but still not work. Please help

Request URL: http://localhost:5000/api/client/ImportClientDemographic
Request Method: OPTIONS
Status Code: 401 Unauthorized
Remote Address: [::1]:5000
Referrer Policy: no-referrer-when-downgrade
Cache-Control: private
Content-Length: 6108
Content-Type: text/html; charset=utf-8
Date: Thu, 12 Sep 2019 20:48:49 GMT
Server: Microsoft-IIS/10.0
WWW-Authenticate: Negotiate, NTLM
X-Powered-By: ASP.NET
X-SourceFiles: =?UTF-8?B?QzpcWWFvbWluZ1xFSVNcTm9uUmVzXEVJU05vblJlcy5BcGlcYXBpXGNsaWVudFxJbXBvcnRDbGllbnREZW1vZ3JhcGhpYw==?=
Provisional headers are shown
Access-Control-Request-Method: POST
Origin: http://localhost:4200
Referer: http://localhost:4200/
Sec-Fetch-Mode: no-cors
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36

hi, i am trying to implement the server API (dotnet core 2.2)with Active Directory authentication. And on my client side, i am using Angular 8 with ng2-file-upload. I keep getting an 401 401 Unauthorized with request method: OPTIONS. I already setup the CORS on the server but still not work. Please help Request URL: http://localhost:5000/api/client/ImportClientDemographic Request Method: OPTIONS Status Code: 401 Unauthorized Remote Address: [::1]:5000 Referrer Policy: no-referrer-when-downgrade Cache-Control: private Content-Length: 6108 Content-Type: text/html; charset=utf-8 Date: Thu, 12 Sep 2019 20:48:49 GMT Server: Microsoft-IIS/10.0 WWW-Authenticate: Negotiate, NTLM X-Powered-By: ASP.NET X-SourceFiles: =?UTF-8?B?QzpcWWFvbWluZ1xFSVNcTm9uUmVzXEVJU05vblJlcy5BcGlcYXBpXGNsaWVudFxJbXBvcnRDbGllbnREZW1vZ3JhcGhpYw==?= Provisional headers are shown Access-Control-Request-Method: POST Origin: http://localhost:4200 Referer: http://localhost:4200/ Sec-Fetch-Mode: no-cors User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36
thopah commented 2019-09-12 21:03:03 +00:00 (Migrated from github.com)

below is the error message shown on console

zone-evergreen.js:2952 OPTIONS http://localhost:5000/api/client/ImportClientDemographic 401 (Unauthorized)
scheduleTask @ zone-evergreen.js:2952
scheduleTask @ zone-evergreen.js:378
onScheduleTask @ zone-evergreen.js:272
scheduleTask @ zone-evergreen.js:372
scheduleTask @ zone-evergreen.js:211
scheduleMacroTask @ zone-evergreen.js:234
scheduleMacroTaskWithCurrentZone @ zone-evergreen.js:1107
(anonymous) @ zone-evergreen.js:2985
proto. @ zone-evergreen.js:1428
push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader._xhrTransport @ file-uploader.class.js:302
push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader.uploadItem @ file-uploader.class.js:105
push../node_modules/ng2-file-upload/file-upload/file-item.class.js.FileItem.upload @ file-item.class.js:30
(anonymous) @ ExcelUploadComponent.html:77
handleEvent @ core.js:43992
callWithDebugContext @ core.js:45631
debugHandleEvent @ core.js:45246
dispatchEvent @ core.js:29803
(anonymous) @ core.js:42924
(anonymous) @ platform-browser.js:2668
invokeTask @ zone-evergreen.js:391
onInvokeTask @ core.js:39679
invokeTask @ zone-evergreen.js:390
runTask @ zone-evergreen.js:168
invokeTask @ zone-evergreen.js:465
invokeTask @ zone-evergreen.js:1603
globalZoneAwareCallback @ zone-evergreen.js:1629
localhost/:1 Access to XMLHttpRequest at 'http://localhost:5000/api/client/ImportClientDemographic' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

below is the error message shown on console zone-evergreen.js:2952 OPTIONS http://localhost:5000/api/client/ImportClientDemographic 401 (Unauthorized) scheduleTask @ zone-evergreen.js:2952 scheduleTask @ zone-evergreen.js:378 onScheduleTask @ zone-evergreen.js:272 scheduleTask @ zone-evergreen.js:372 scheduleTask @ zone-evergreen.js:211 scheduleMacroTask @ zone-evergreen.js:234 scheduleMacroTaskWithCurrentZone @ zone-evergreen.js:1107 (anonymous) @ zone-evergreen.js:2985 proto.<computed> @ zone-evergreen.js:1428 push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader._xhrTransport @ file-uploader.class.js:302 push../node_modules/ng2-file-upload/file-upload/file-uploader.class.js.FileUploader.uploadItem @ file-uploader.class.js:105 push../node_modules/ng2-file-upload/file-upload/file-item.class.js.FileItem.upload @ file-item.class.js:30 (anonymous) @ ExcelUploadComponent.html:77 handleEvent @ core.js:43992 callWithDebugContext @ core.js:45631 debugHandleEvent @ core.js:45246 dispatchEvent @ core.js:29803 (anonymous) @ core.js:42924 (anonymous) @ platform-browser.js:2668 invokeTask @ zone-evergreen.js:391 onInvokeTask @ core.js:39679 invokeTask @ zone-evergreen.js:390 runTask @ zone-evergreen.js:168 invokeTask @ zone-evergreen.js:465 invokeTask @ zone-evergreen.js:1603 globalZoneAwareCallback @ zone-evergreen.js:1629 localhost/:1 Access to XMLHttpRequest at 'http://localhost:5000/api/client/ImportClientDemographic' from origin 'http://localhost:4200' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
deshack commented 2019-12-01 18:23:05 +00:00 (Migrated from github.com)

Hi,
It really looks like a CORS issue. Please, check if you are correctly setting the Access-Control-Allow-Origin header.
If it is, please give us details about the OPTIONS call response (headers and body).

Hi, It really looks like a CORS issue. Please, check if you are correctly setting the `Access-Control-Allow-Origin` header. If it is, please give us details about the OPTIONS call response (headers and body).
MANAYATHU commented 2022-07-21 05:26:48 +00:00 (Migrated from github.com)

localhost:5000/api/gList/?zone.js:2863 =user::3 401 (Unauthorized)

localhost:5000/api/gList/?zone.js:2863 =user::3 401 (Unauthorized)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#1109