在 Ionic 中进行 HTTP get 调用后跟 CORB 警告后,响应为空

Response is coming as null after making HTTP get call followed by CORB warning in Ionic

无法弄清楚为什么响应是 null

当使用模拟数据进行测试时,它工作得很好,但是当我试图访问我们在 AWS EC2 中托管的 API 时,响应为 null 并且出现错误消息在控制台中如下

Cross-Origin Read Blocking (CORB) blocked cross-origin response http://example.com/search/api?limit=10&offset=10 with MIME type application/json. See https://www.chromestatus.com/feature/5629709824032768 for more details.

但是,我在浏览器的网络选项卡中验证,它显示 200 OK。另外,我用 Postman 客户端验证了这个 API 调用,并且正在显示数据。

我尝试了多种方法来禁用 Chrome 浏览器中的网络安全选项,但没有成功。我的 Chrome 浏览器中也有 CORS 扩展。

任何人都可以指导我在这里做错了什么。

服务

import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Injectable({
  providedIn: 'root'
})
export class SearchService {

  searchUrl = 'http://example.com/search/api?limit=10&offset=10'
  mockDataUrl = 'https://jsonplaceholder.typicode.com/posts';

  constructor(private httpClient: HttpClient) { }

  getMockData() {
    return this.httpClient.get(this.mockDataUrl);
  }

  getSearchData() {
    return this.httpClient.get(this.searchUrl);
  }

}

组件

export class AppComponent implements OnInit {

  ngOnInit() {
    this.searchService.getSearchData().subscribe(
      (response) => { console.log(response); }
    );
  }
}

这是唯一对我有用的

安装此 extension 并启用后,我就能看到响应。