Cross origin is not happening, blocked by CORS policy.
I am on a Windows system.
In -.service.ts
file:
makeHeaders() {
const headers = new HttpHeaders({
'content':"application/json",
'Content-Type': 'application/x-www-form-urlencoded',
// 'Access-Control-Allow-Credentials': 'true',
'Access-Control-Allow-Origin': 'http://localhost:4200',
'Access-Control-Allow-Methods': 'OPTIONS, GET, POST',
'Access-Control-Allow-Headers': 'Origin, Content-Type, Accept, Access-Control-Allow-Origin, Authorization, X-Requested-With'
})
return headers;
}
in proxy.conf.json
file:
"target": "http://localhost:1111"
I got this error in the browser console:
Access to XMLHttpRequest at 'http://localhost:1111/api/v1/employees/create' 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. core.js:15724 ERROR HttpErrorResponse {headers: HttpHeaders, status: 0, statusText: "Unknown Error", url: "http://localhost:1111/api/v1/employees/create", ok: false, …}
Thanks