原文:axios跨域请求报错:Request header field content-type is not allowed by Access-Control-Allow-Headers in preflight response.

在做项目时,用到axios,数据用post提交时,老是报错,错误提示为: 如下图: 仔细看看自己跨域配置,设置成这样: 这是因为我在后端设置跨域请求的时候没有所需的请求类型。于是做了如下修改: 结果就可以啦。 ...

2019-09-06 11:49 0 5562 推荐指数:

查看详情

请求错误: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource

今天在学习Angular 的HttpInterceptor 拦截器时,发现添加了新的headers键值之后总是报错误。后台使用的是asp.net core。 检查发现,在添加了新的header之后,每次请求之前都会先发送一个options请求,这个请求被后台拒绝了,所以导致报错。我的后台 ...

Sat Jul 13 01:39:00 CST 2019 1 10123
 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM