在香草js的HTTP(不是https) post请求



我正在尝试(对于一个小的个人项目)发送一个http(不是https,因为我没有设置)到我的vps运行nodejs。我可以用postman完美地发送请求,但是尝试使用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,这将解决这个问题。如何启用cors nodejs与express?

如果没有,请提供更多的代码/上下文

最新更新