angular - Angular 6:Http 失败响应(Microsoft Edge)
问题描述
我正在尝试调用 API,但是在使用 M Edge 时遇到了问题(Chrome、IE 和 Firefox 都可以)。对于我尝试执行的每个请求,我都会在控制台中收到以下错误:
这是我的服务:
@Injectable({ providedIn: 'root' })
export class AuthService {
constructor(private http: HttpClient) {}
signup(
firstName: string,
lastName: string,
email: string,
country: string,
password: string
) {
const data = {
firstName: firstName,
lastName: lastName
};
const headers = new HttpHeaders({
'Content-Type': 'application/json; charset=utf-8'
});
return this.http.post('https://api.lan/new/', data, {
headers: headers,
observe: 'response'
});
}
}
API Nginx 配置:
server {
listen 80;
listen [::]:80;
server_name visionapi-dev.arkadin.lan;
root /var/www/online-vision-api/httpdocs;
error_log /var/www/online-vision-api/logs/error_log;
access_log /var/www/online-vision-api/logs/access_log;
index index.php;
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow_Credentials' 'true' always;
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always;
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always;
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow_Credentials' 'true' always;
add_header 'Access-Control-Allow-Headers' 'Authorization,Accept,Origin,DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Content-Range,Range' always;
add_header 'Access-Control-Allow-Methods' 'GET,POST,OPTIONS,PUT,DELETE,PATCH' always;
add_header 'Access-Control-Max-Age' 1728000 always;
add_header 'Content-Length' 0 always;
return 204;
}
# Check if a file or directory index file exists, else route it to index.php.
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_read_timeout 180;
}
}
我已经疯狂地谷歌了,有人知道吗?
谢谢!
解决方案
推荐阅读
- javascript - 反应本机 msal 尝试调用接口方法 ReadableMap.getArray(java.lang.String)
- python - 如何在已经服务于 PHP 网站的 Ubuntu 服务器上运行基于 Flask 的网页
- javascript - JavaScript如何解析node.js中的查询
- java - 带有对话框的谷歌地图标记过滤器
- java - FileReader 找不到文件
- postgresql - Aurora 如何分发 Postgres 函数来读写副本?
- azure-ad-b2c - 如何通过 Microsoft Authenticator App 添加 MFA 作为电子邮件后的第二个因素,登录流程中的密码身份验证
- linked-list - 合并两个链表失败
- reactjs - 测试 React Material-UI Snackbar - Notistack
- css - vue 样式仅在我执行 ::deep 时应用,即使它不是组件样式。为什么?