控制台报的错误是:

Access to XMLHttpRequest at 'http://localhost:3000/error' from origin 'null' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
GET http://localhost:3000/error net::ERR_FAILED

而不是400状态码

所以我们需要在app.js文件中加入

app.all('*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By", ' 3.2.1')
res.header("Content-Type", "application/json;charset=utf-8");
next();
}); app.get('/error', (req, res) => {
res.status(400).send('not ok'); })
这样就解决了这个问题

最新文章

  1. java1.8函数式编程概念
  2. 升级win8.1后mysql服务不能启动的问题
  3. js中的this指针(四)
  4. Address already in use: JVM_Bind<null>:8080错误的解决办法
  5. Linux共享内存(一)
  6. mysql事务问题
  7. 新浪微博授权时出现"关注 *** 的微博"
  8. Deep learning From Image to Sequence
  9. 配置两个Hadoop集群Kerberos认证跨域互信
  10. spark submit参数调优
  11. 基于opencv和QT的摄像头采集代码( GoQTtemplate3持续更新)
  12. python rabittmq 使用
  13. 【存储过程】用SQL语句获得一个存储过程返回的表
  14. html基础代码示例
  15. part1:7-Linux网络配置
  16. Python 中单双引号
  17. 一个完成的spring xml配置文件
  18. ubuntu下超强的截图工具scrot
  19. 019——VUE中v-for与computer结合功能实例讲解
  20. 内存修改之IOS版ce

热门文章

  1. Numpy库基础___四
  2. request的自动urlencode问题解决
  3. 如何运行MATLAB和C++混合编程
  4. spring-注解驱动模式
  5. 什么是 Daemon 线程?它有什么意义?
  6. 接口是否可继承(extends)接口?抽象类是否可实现 (implements)接口?抽象类是否可继承具体类(concrete class)?
  7. spring-boot-learning-REST风格网站
  8. CKEditor禁用浏览服务器的功能
  9. 哪些是重要的 bean 生命周期方法?你能重载它们吗?
  10. AGENS算法