[英]http (not https) post request in vanilla js
我正在尝试(对于一个小型个人项目)向运行 nodejs 的 vps 发送 http(不是 https,因为我没有设置它)。 我可以用邮递员完美地发送请求,但尝试使用 xmlhttprequest 会在控制台打印以下错误:
Access to XMLHttpRequest at 'http://207.154.211.105/?postBidone={%22id%22:{%22nome%22:%22esempio1%22,%22localita%22:%22esempio2%22,%22extra%22:%22esempio3%22},%22action%22:%22add%22,%22content%22:%22plastic%22}' from origin 'null' has been blocked by CORS policy: Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.
您知道成功发送请求的方法吗? 谢谢!
请查看这篇文章并启用 CORS,这将解决此问题。 如何使用 express 启用 cors nodejs?
如果没有,请提供更多代码/上下文。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.