Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
505 views
in Technique[技术] by (71.8m points)

angular - 对预检请求的响应未通过访问控制检查:它没有HTTP正常状态(Response to preflight request doesn't pass access control check: It does not have HTTP ok status)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...