【发布时间】:2023-03-26 20:29:01
【问题描述】:
我正在尝试创建一个页面,让您可以上传文件并在其中搜索某些值,但是当我尝试从 firebase 存储中获取文件时,它给了我一个错误
CORS 策略阻止了从源“mysite”在“theurl”处获取的访问权限:请求的资源上不存在“Access-Control-Allow-Origin”标头。如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。
是的,我尝试将 mod 设置为 no-cors,这有点用,但 fetch 返回一个空白 txt 文件。这是我的代码,请帮忙。谢谢
storageRef.child('thefilepath').getDownloadURL().then(function (url) {
document.getElementById("atextbox").value = url
})
var dictionaryurl = document.getElementById("atextbox").value
fetch(dictionaryurl)
.then(r => r.text())
.then(t => {mycodethatrunsafter});
【问题讨论】:
标签: javascript firebase fetch firebase-storage