我很沮丧地发布了类似的问题,但花了 3 天多的时间却无法解决问题。
\n\n平台:Ionic 4 Angular 7
\n\n当我尝试发布时,出现 cors 政策错误。
\n\n从来源 \' http://localhost:8100 \' 访问 \' https://mersinders.com/api/service.php?run=giris \'处的 XMLHttpRequest已被 CORS 策略阻止:对预检请求的响应不会未通过访问控制检查:它没有 HTTP 正常状态。
\n\n当我禁用 chrome 安全性时,一切正常。
\n\n\n\n\n“C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe”\n --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp
\n
HttpErrorResponse\xc2\xa0{标头:HttpHeaders,状态:400,statusText:“错误请求”,url:“ https://mersinders.com/api/service.php?run=giris ”,好的:false,\xc2\ xa0\xe2\x80\xa6}
\n\n在 Php api 端使用以下标头后,问题开始出现。
\n\n\n\n\nheader(\'状态: 400\', TRUE, 400); header(\'状态: 404\', TRUE, 404);
\n
我有 config.ini.php 其中包括数据库信息和连接,以及 service.php 切换大小写 "service.php?run=XXXXX" 。
\n\n当我在 service.php 中设置标头时
\n\n\nheader(\'Access-Control-Allow-Origin: *\');
\n header("Access-Control-Allow-Credentials: true");
\n …