Skip to content
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

跨域失败 #36

Open
eightHundreds opened this issue Jun 26, 2019 · 5 comments
Open

跨域失败 #36

eightHundreds opened this issue Jun 26, 2019 · 5 comments

Comments

@eightHundreds
Copy link

跨域时候请求似乎还是会打到服务器
但是服务器报了500错误,导致跨域请求还是失败了
有没有办法拦截Option请求,让响应码总是200

@eightHundreds
Copy link
Author

问题2

自定义请求头不再response的access-control-allow-headers,导致跨域失败

问题3

配置了地址重写和跨域时

Options请求返回的状态码是307 Internal Redirect 导致跨域失败

@netbeen
Copy link

netbeen commented Mar 9, 2020

我也遇到了同样的问题,当<script>标签里增加了crossorigin 属性后,XSwitch代理失败,反馈错误:
Access to script at 'http://127.0.0.1:9000/build/vendor.js' (redirected from 'https://g.alicdn.com/ais-fed/ak-static/3.3.23/vendor.js') from origin 'https://rdc.aliyun.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
(之所以需要增加crossorigin,是为了使用React Errorboundary捕获异常,如果不加crossorigin则无法展示错误信息)

@izuomeng
Copy link

image

@shirayner
Copy link

我也遇到了这个问题

@IssacSix
Copy link

我也遇到了同样的问题,当<script>标签里增加了crossorigin 属性后,XSwitch代理失败,反馈错误: Access to script at 'http://127.0.0.1:9000/build/vendor.js' (redirected from 'https://g.alicdn.com/ais-fed/ak-static/3.3.23/vendor.js') from origin 'https://rdc.aliyun.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. (之所以需要增加crossorigin,是为了使用React Errorboundary捕获异常,如果不加crossorigin则无法展示错误信息)

想保留crossorigin的话 可以尝试一下解决跨域问题,给你的本地服务设置跨域白名单(CORS)如果是webpack 可以参考:https://stackoverflow.com/questions/31602697/webpack-dev-server-cors-issue,其他的服务也可以做对应设置

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants