我正在使用Angular 10 Service Worker订阅推送通知。我在登录后调用此函数:
subscribeToNotifications(): void {
this.swPush.requestSubscription({
serverPublicKey: environment.vapidPublicKey
})
.then(sub => this.deviceService.subscribeDevice(sub).subscribe())
.catch(err => console.error('Could not subscribe to notifications', err));
}
函数subscribeDevice()如下所示:
public subscribeDevice(sub): Observable<any> {
return this.http.post(`${this.API_URL}/devices/webpush/`, sub, this.options);
}
我使用http-server服务,如下所示:
http-server -p 4200 -c-1 dist/produccion-angular
但是,在执行函数时,504网关超时:
我检查了我的后端日志,请求甚至都没有完成,所以很明显不是服务器。该怎么办呢。我阅读了angular文档中关于绕过服务工作者的部分,并让浏览器处理请求,但随后发生了以下情况:
发布于 2020-11-30 11:58:59
问题是由我在Chrome中安装的广告拦截器扩展引起的。
https://stackoverflow.com/questions/65067346
复制相似问题