@sam A very similar thread on SO details possible solutions for this problem with angular apps. I hope this can help.
calling languge detection from angular app showing Blocked by CORS policy
sam
201
Reputation points
Calling text detection azure container instance url from angular app getting below error.
Error: Access to XMLHttpRequest at 'http://myurl/text/analytics/v2.0/languages' 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.
identifyLanguage(data: any) {
var payload = {
"documents": [
{
"id": "1",
"text": "This is for testing"
}
]
}
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json; charset=utf-8'
})
};
return this.http.post<any>
('http://myurl/text/analytics/v2.0/languages',JSON.stringify(payload),httpOptions)
}
1 answer
Sort by: Most helpful
-
romungi-MSFT 43,621 Reputation points Microsoft Employee
2021-07-15T13:32:58.897+00:00