我在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);
}
}
**
这是输出响应
这里是没有CacheInterceptor的输出
这是我在其中调用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);
}
}