角度阻塞的心

问题描述

在我的本地主机中,我已禁用了Google chrome安全性,但是知道我想在服务器中部署它,并且遇到了这个核心问题。 该API不是我自己的外部API。

Core Error Image

我在打字稿中的服务是

getPlaces(holiday_type,currency,checkin,checkout,groups,page) {
    return this.http.get(
      `/api/v2/places?holiday_type=${holiday_type}&currency=${currency}&checkin=${checkin}&checkout=${checkout}&groups[]=${groups}&page=${page}`,{
        headers: {
          'Authorization': this.auth,'Accept': 'application/json','Access-Control-Allow-Origin': '*','Access-Control-Allow-Methods': 'GET,POST,PUT,DELETE,OPTIONS','Access-Control-Allow-Headers': 'Content-Type,Access-Control-Allow-Headers,Access-Control-Allow-Origin,Authorization,X-Requested-With',},});
}

我的proxy.config看起来如此

{
  "/api/*":  {
    "target": "https://tr.halalbooking.com","secure": false,"logLevel": "info"
  }
}

解决方法

从错误消息中看来, halabookings 正在阻止该请求。您有两种选择:

  1. 联系halalbookings的所有者,并要求他们允许您出身。通常,如果他们为您提供API,则您会拥有一个门户,您可以在其中将白名单或指定允许的来源。

  2. 将API调用移至halalbooking,以在服务器端进行。然后,在您的前端,调用您的API(调用halalbookings)