return this.http.get<any>('https://test.p-44.com/api/v3/tl/shipments/'+id+'/statuses?includeMapUrl=true', {
headers:
new HttpHeaders()
.append('Accept', 'application/json')
.append('Content-Type', 'application/json')
.append('Authorization', 'Basic ' + btoa("xxxxx:xxx"))
, responseType: 'json'
})
.map((response: Response) => <any>response)
Here is my service call of the Api, this will return an error :
Failed to load https://test.p-44.com/api/v3/tl/shipments/1252/statuses?includeMapUrl=true: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'https://dev.18th-avenue.com' is therefore not allowed access. The response had HTTP status code 401.
But this call will work perfectly fine on my locahost when I use a proxy config as :
const PROXY_CONFIG = [
{
context: [
"/44",
],
target: "https://test.p-44.com",
secure: false,
changeOrigin: true,
pathRewrite: {"^/44" : ""}
}
]
module.exports = PROXY_CONFIG;
return this.http.get<any>('/44/api/v3/tl/shipments/'+id+'/statuses?includeMapUrl=true', {
headers:
new HttpHeaders()
.append('Accept', 'application/json')
.append('Content-Type', 'application/json')
.append('Authorization', 'Basic ' + btoa("pmorin@18th-avenue.com:Action18!"))
, responseType: 'json'
})
.map((response: Response) => <any>response)
Do you have any idea why this proxy call works but the one without does not? I use IIS server, do I need to add a config there or something? When I will build my application on my server, I won't be able to use that proxy
Thank you