问答详情
源自:5-3 前后端数据交互

XMLHttpRequest cannot load http://127.0.0.1:8090/api/list. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

XMLHttpRequest cannot load http://127.0.0.1:8090/api/list. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

提问者:慕设计7486976 2019-06-14 16:44

个回答

  • power涛
    2019-06-15 09:34:49

    跨域了,不过你是本地请求一般不会出现。。。有可能你电脑上访问html页面 使用的localhost,host文件里面没有localhost的dns配置?

    在Handler函数内第一行添加w.Header().Set("Access-Control-Allow-Origin", "*"),设置请求的域名可以为任意域名。


  • 慕斯1088534
    2020-11-28 22:09:30

    在函数getFileListHandler中第一行添加w.Header().Set("Access-Control-Allow-Origin", "*"),就解决获取视频列表跨越问题了。?