简体   繁体   English

Angular HTTP请求在Chrome中返回null,但在Firefox中有效

[英]Angular http request return null in chrome but works in firefox

I have faced a strange problem. 我遇到了一个奇怪的问题。 I have been working for two months with this angular 7 project. 我已经为这个angular 7项目工作了两个月。 Everything was working fine. 一切都很好。 But suddenly all my HTTP returns null. 但是突然我所有的HTTP返回null。 But it works as expected in Firefox. 但是它可以在Firefox中按预期工作。 i reinstall chrome and problem disappear but after a day it starts again. 我重新安装了chrome,问题消失了,但是一天后又重新开始了。 we are using laravel as backend API. 我们使用laravel作为后端API。 status code is 200. but returns null. 状态码为200。但返回null。 it is happening in each API (GET, POST). 它发生在每个API(GET,POST)中。 I have tried in another PC and same thing. 我已经尝试在另一台PC和相同的东西。 doesn't work in chrome, works in Firefox. 在chrome中不起作用,在Firefox中起作用。 Can anyone explain? 谁能解释?
service: 服务:

getRecentProjects () {
  return this.http.get(`${ApiUrl}/ati-erp-project`);  
}

component: 零件:

this.homeService.getRecentProjects().subscribe(
      (success: any) => {
        console.log(success)
      }, (error: HttpErrorResponse) => {
        console.log(error);
      }
    )

Surprisingly. 出奇。 its a CORS issue. 这是一个CORS问题。 I have been tackling CORS issue with plugin for a long time specially when my back end don't have any headers or permission. 很长时间以来,我一直在处理插件的CORS问题,特别是当我的后端没有任何标题或权限时。 But suddenly even after activation of CORS plugin HTTP response was null. 但是突然之间,即使在激活CORS插件后,HTTP响应也为空。 when we configured back end with authorization header it works again. 当我们使用授权标头配置后端时,它可以再次工作。 So, maybe its new policy for chrome its doesn't show you an error of CORS when you use plugin but returns null in response body. 因此,也许其针对chrome的新策略在您使用插件时不会向您显示CORS错误,而是在响应正文中返回null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Chrome / Safari和Firefox中的Angular Http Get返回不同 - Angular Http Get return different in Chrome/Safari vs Firefox angular 7 http post在edge和firefox上工作但在chrome上返回错误 - angular 7 http post work on edge and firefox but return error on chrome Angular 5 HttpClient Firefox PUT未执行,但可在Chrome中使用 - Angular 5 HttpClient Firefox PUT not executed but works in Chrome Angular HTTP 请求返回 406 - Angular HTTP request return 406 角度:POST 请求返回 null - ANGULAR : POST request return null Angular 5 Http api请求在chrome dev工具中得到响应,但不会返回 - Angular 5 Http api request gets response in chrome dev tools but won't return Angular HTTP请求有效,但HttpClient失败 - Angular HTTP Request Works, but HttpClient Fails $(document).ready Angular 项目代码中的 Javascript 适用于 Edge 但不适用于 chrome 或 firefox - $(document).ready Javascript in Angular project code works on Edge but not chrome or firefox Angular2应用程序适用于Chrome和IE,但不适用于Firefox或Safari - Angular2 app works in Chrome and IE, but not Firefox or Safari (Angular) 需要帮助在 IE 中下载 cvs 文件,它适用于 Chrome 和 Firefox - (Angular) Need help to download a cvs file in IE, it works on Chrome and Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM