alibaba / anyproxy

A fully configurable http/https proxy in NodeJS
http://anyproxy.io
Apache License 2.0
7.83k stars 1.22k forks source link

用 fetch 请求时错误 #58

Open foxundermoon opened 8 years ago

foxundermoon commented 8 years ago

错误信息如下,求解答

Fetch API cannot load http://127.0.0.1:8001/api/app/5715e829a14a74d2227b98f6. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
foxundermoon commented 8 years ago

只设置 port就会出现这错误。 需要同时指定host。这坑藏的好深,完全靠运气试出来的。

ottomao commented 8 years ago

是用了 replaceRequestOption方法? 这里的参数参考这篇文档: https://nodejs.org/api/http.html#http_http_request_options_callback

On Fri, Apr 22, 2016 at 5:51 PM, foxundermoon notifications@github.com wrote:

只设置 port就会出现这错误。 需要同时指定host。这坑藏的好深,完全靠运气试出来的。

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/alibaba/anyproxy/issues/58#issuecomment-213362333

Mao Xiaofeng(茅晓锋) Profession: F2E Tel:(86) 15801916167 _Email:_ottomao@gmail.com SinaWeibo:@茅晓锋Otto http://www.weibo.com/ottomao _Blog:_ottomao.com

codingfishman commented 8 years ago

@foxundermoon 可否描述一下是在何种情形下出现的这个错误,有没有使用replaceRequestOption方法?或是说默认的anyproxy时fetch报错了。