Предварительный запрос не проходит контроль доступа
Я хотел бы интегрировать Zoho Desk API в мое угловое приложение, когда я вызываю GET
Я получаю эту ошибку: "Не удалось загрузить https://desk.zoho.com/api/v1/tickets?include=contacts: Ответ на предпечатный запрос не проходит проверку контроля доступа: Нет" Access-Control-Allow-Origin " в запрошенном ресурсе присутствует заголовок. Исходный код " http://localhost:4200/", следовательно, не имеет доступа. Ответ имеет HTTP-код состояния 405"
Мой перехватчик, чтобы добавить информацию заголовков
import { Injectable } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { Observable } from 'rxjs/observable';
@Injectable()
export class ZohoAuthInterceptor implements HttpInterceptor {
intercept (req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
const authReq = req.clone({
headers: req.headers.set('orgId', 'myorgId')
.set('Authorization', 'myAuth')
});
return next.handle(authReq);
}
}
И в моем компоненте.ц
constructor(private http:HttpClient) {
this.http.get('https://desk.zoho.com/api/v1/tickets?include=contacts').subscribe(data => {
console.log(data);
});
}