angular6 - 在 ANGULAR 6 控制台来源“http://localhost:4200”中出现错误已被 CORS 策略阻止
问题描述
Angular 6 -> 我正在使用应用程序/json 在 POST 请求中发送数据。当我击中这个时,我得到
请求方法:OPTIONS 状态码:200 OK
但是在控制台中出现 Cors 问题。我检查了所有示例和文档。此请求在 POSTMAN 中运行
import { Http, Headers, RequestOptions } from "@angular/http";
let headers = new Headers();
headers.set("Content-Type", "application/json");
let option = new RequestOptions();
option.headers = headers;
return this.http.post(this.url, JSON.stringify(this.data), option);
解决方案
推荐阅读
- javascript - 在画布功能组件中使用事件处理程序
- r - 在 dplyr 中使用不同的分组变量进行总结
- java - 从终端运行 Gradle 程序的问题
- ios - UITextField 编辑时自定义背景颜色
- azure - QnA Maker 知识库未显示
- javascript - Vue.JS、Axios、CanvasJS - 从 API 获取数据并填充/渲染图表
- c++ - 错误与
在 C++、Windows 中使用库时 - sql-server - VM 和主机之间的 SQL 链接服务器配置
- sharepoint-online - SharePoint SPFX(无框架)如何从 onclick 调用函数
- architecture - 具有 API 网关和微服务的 Blazor 服务器指南