-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
接口测试的时候出现跨域问题,可是后端已经开启跨域了 #15
Comments
你这个开启跨域的后端,不是指 api-mocker的服务端吧?api-mocker服务端默认就是开启跨域的 |
不是,是我们自己的服务端开启了跨域。我这边点击测试的时候,看console里面的报错好像是localhost不能去请求。有点疑问 |
用postman测试接口的时候,能成功 |
@Ttxy0105 postman测试接口,本来也不会存在跨域问题的。http://oyrpdvj2f.bkt.clouddn.com/ 方便的话,你可以先在我这个测试的api-mocker系统里注册一个账号,再上面编辑下你们这个接口,我再去调试看看 |
我大概知道原因了,你把服务端允许跨域关了,应该就好了,目前api-mocker的测试prod跟dev,还有代理模式的转发,都是服务端发起的代理请求,不需要服务端开启跨域的。不过你这开启跨域反而出问题,确实是个bug,我回头看看解决下。 @Ttxy0105 |
@wuomzfx 谢谢,最近也准备部署在服务器上,把公司的文档转到api-mocker上面 |
@Ttxy0105 好,感谢反馈跟支持~ |
@Ttxy0105 不好意思,刚去测试链接上 看了下,不是我刚刚说的原因。请求结果成功了,只是你们返回的接口请求头是Content-Type:text/html; charset=utf-8,不是json格式的,解析失败了。你直接转发代理再去浏览器里打开其实是ok的。我看看怎么优化下这个错误提示,现在没catch对error |
@Ttxy0105 config.withCredentials 这个不能关,根本问题不是这里 |
@Ttxy0105 另外,你们的接口我暂时拿来做下测试蛤。 |
@wuomzfx 但是 |
@wuomzfx 好的,辛苦啦。 |
@Ttxy0105 我没有尝试过,应该是没问题的,有问题可以随时跟我说,github没反应的话,可以加我微信,75851654 |
The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. Origin 'http://localhost:8080' is therefore not allowed access. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.
The text was updated successfully, but these errors were encountered: