My back-end is running locally on localhost:8090/
and front-end is running on http://localhost:4200/
.
(我的后端在localhost:8090/
上localhost:8090/
运行,而前端在http://localhost:4200/
。)
I'm trying to send a POST request to back-end with some data in body and I'm getting this error in browser console. (我正在尝试向正文发送一些数据的后端POST请求,并且在浏览器控制台中遇到此错误。)
Access to XMLHttpRequest at ' http://localhost:8090/process/ ' from origin ' http://localhost:4200 ' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status.
(从源' http:// localhost:4200 '的' http:// localhost:8090 / process / '处对XMLHttpRequest的访问已被CORS策略阻止:对预检请求的响应未通过访问控制检查:没有HTTP正常状态。)
Angular Service Function
(角服务功能)
createProcess(){
const url = 'http://localhost:8090/process/';
return this.http.post<any>(url, { "botType": "test1", "name": "test2", "processCode": "test3" })
.pipe(map(user => {
return user;
}));
}
Swagger-UI
(Swagger-UI)
This works in POSTMAN.
(这在POSTMAN中有效。)
What I'm doing wrong here ? (我在这里做错了什么?)
ask by Lalinda Sampath translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…