admin管理员组文章数量:1392059
i get this error when loading a json file :
Failed to load http://localhost/sandbox/data.json?_=1505732125859: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.
#...
from flask_cors import CORS
app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})
@app.route('/')
def index():
return render_template('index.html')
Tried this solution.. but still getting same error Javascript - No 'Access-Control-Allow-Origin' header is present on the requested resource
i get this error when loading a json file :
Failed to load http://localhost/sandbox/data.json?_=1505732125859: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:5000' is therefore not allowed access.
#...
from flask_cors import CORS
app = Flask(__name__)
CORS(app, resources={r"/*": {"origins": "*"}})
@app.route('/')
def index():
return render_template('index.html')
Tried this solution.. but still getting same error Javascript - No 'Access-Control-Allow-Origin' header is present on the requested resource
Share Improve this question asked Sep 18, 2017 at 10:58 deepak murthydeepak murthy 4113 gold badges6 silver badges21 bronze badges 4-
Is that python code running on
http://localhost
orhttp://localhost:5000
? – Quentin Commented Sep 18, 2017 at 11:02 - yes python code is running...output is stored in json file.. when accessing that json using jquery. getting this error – deepak murthy Commented Sep 18, 2017 at 11:44
-
3
I was expecting your answer to be "
http://localhost
" or"http://localhost:5000
". "Yes" doesn't help me help you! – Quentin Commented Sep 18, 2017 at 12:44 - running on "localhost:5000". – deepak murthy Commented Sep 18, 2017 at 12:45
1 Answer
Reset to default 3You've set the CORS permissions on the wrong server.
A webpage on http://localhost:5000
is making a request to http://localhost
.
Your headers are granting permission to every site (*
) to access the data on http://localhost:5000
, but you are trying to access the data on http://localhost
.
You need to set the CORS permissions on http://localhost
instead.
This answer explains the background.
本文标签: javascriptPython FlaskNo 39AccessControlAllowOrigin39Stack Overflow
版权声明:本文标题:javascript - Python Flask - No 'Access-Control-Allow-Origin' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744783251a2624842.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论