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

如何解决http请求跨域问题?Mac下file://也没反应 #37

Open
jkfaner opened this issue Jan 9, 2022 · 5 comments
Open

如何解决http请求跨域问题?Mac下file://也没反应 #37

jkfaner opened this issue Jan 9, 2022 · 5 comments

Comments

@jkfaner
Copy link

jkfaner commented Jan 9, 2022

Access to script at 'http://localhost:5000/xxxxx' (redirected from 'https://www.xxxx.com/xxx/xx/xx.') from origin 'https://www.xxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

@jkfaner jkfaner changed the title 如何解决http请求跨域问题?Mac下fille://也没反应 如何解决http请求跨域问题?Mac下file://也没反应 Jan 9, 2022
@jkfaner
Copy link
Author

jkfaner commented Jan 9, 2022

已解决

@13632225945
Copy link

请问是怎么解决的

@suyunxue
Copy link

suyunxue commented Jun 6, 2022

怎么解决的呢,我也遇到跨域问题了

@shuaiqileilei
Copy link

Access to script at 'http://localhost:5000/xxxxx' (redirected from 'https://www.xxxx.com/xxx/xx/xx.') from origin 'https://www.xxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

同问怎么解决的

@jkfaner
Copy link
Author

jkfaner commented Jun 1, 2023

Access to script at 'http://localhost:5000/xxxxx' (redirected from 'https://www.xxxx.com/xxx/xx/xx.') from origin 'https://www.xxxx.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

同问怎么解决的

使用python的Flask搭建web服务时:

import webbrowser
from flask import Flask
from flask_cors import CORS

app = Flask(__name__)
CORS(app) # 关键

@app.route("/test")
def test():
    return app.send_static_file("test.js")

if __name__ == "__main__":
    webbrowser.open("http://127.0.0.1:5000")
    app.run()

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

4 participants