I try to access another Rest service outside from Alfresco via ADF. Everytime I try to execute the call. I get the following error:
Access to XMLHttpRequest at 'https:/host/endpoint' 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.
I also added the endpoint to the proxy.conf.json
"/endpoint": {
"target": "https://hostname",
"secure": false,
"changeOrigin": true
}
With the same result as before.
I use the following class:
export class ClassService {
constructor(private http: HttpClient) {
}
private getLoginHeader(username: string, password: string) {
let Headers: HttpHeaders = new HttpHeaders();
console.log('Header ' + 'Basic ' + btoa(username + ':' + password));
Headers = Headers.append('Authorization', 'Basic ' + btoa(username + ':' + password));
Headers = Headers.append('Access-Control-Allow-Origin', '*');
Headers = Headers.append('Content-Type', 'application/x-www-form-urlencoded');
console.log(Headers);
return Headers;
}
getBatchClasses(username: string, password: string ) {
return this.http.get<any>('/dendpoint',
{headers: this.getLoginHeader(username, password)}).subscribe(response => {
console.log(response);
}, err => {
console.log('User authentication failed!');
});
}
logout() {
localStorage.removeItem('token');
}
}If I try to access it with Postman it works properly. That sounds for me, that ADF forces to use a repository webscript to access external resources. Is this correct? If not can somebody give me a hint?
Regards
Kaffi