首页 > 解决方案 > 在 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);

标签: angular6

解决方案


推荐阅读