Angularar api在Chrome中工作,但在Fire fox中工作吗?

问题描述 投票:0回答:1

我在php中有一个代理api文件,在angular 7中有一个前端。我的api从chrome返回数据并在fire fox中返回错误

这里是当我在其中添加缓存拦截器时的响应角度应用]

  providers: [
     { provide: HTTP_INTERCEPTORS, useClass: CacheInterceptor, multi: true }
  ],

这是我的CacheInterceptor文件中的代码

import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpHeaders } from '@angular/common/http';

@Injectable()
export class CacheInterceptor implements HttpInterceptor {
  intercept(req: HttpRequest<any>, next: HttpHandler) {
    const httpRequest = req.clone({
      headers: new HttpHeaders({
        'Cache-Control': 'no-cache',
        Pragma: 'no-cache'
        // 'Expires': 'Sat, 01 Jan 2000 00:00:00 GMT',
      })
    });

    return next.handle(httpRequest);
  }
}

**

这是输出响应

**enter image description here

这里是没有CacheInterceptor的输出

enter image description here

这是我在其中调用api的代码

import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Global } from '@env/app.global';
import { environment } from '../environments/environment';
import { Subject } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class HeaderService {
  onUserNameUpdate: Subject<string>;
  constructor(public http: HttpClient) {
    this.onUserNameUpdate = new Subject();
  }

  public getHeaderAdd(url: any): any {

      return this.http.get(environment.serverUrl + Global._API_HOME_CMS);

  }
}
angular typescript firefox cross-browser
1个回答
0
投票
您是否尝试删除“ Pragma:'no-cache'”标头?显然,仅当您确实需要与HTTP / 1.0协议向后兼容时才需要。
© www.soinside.com 2019 - 2024. All rights reserved.