简体   繁体   中英

cors(cors policy: Response to preflight request doesn't pass access control check) error in angular 7

从源' http:// localhost:4200 '的' http://192.168.1.30/v1w/?tag=login '处对XMLHttpRequest的访问已被CORS策略阻止:对预检请求的响应未通过访问控制检查:它没有HTTP正常状态。

Here are possible solutions

  1. You need to add CORS headers at your PHP end. Solution is provided in another question CORS with php headers

  2. If you do not want to add CORS, which I recommend when for your production environment, you can setup a reverse proxy using nginx or httpd such that both your http-request and html files are served from same url base

  3. You can also temporarily disable CORS check on browser. Answered here: Does --disable-web-security work in Chrome anymore?

  4. You can also use chrome extension or firefox extension which can disable CORS check for certain domains. Example https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en-US

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM