我目前正在开发一个 Web 应用程序,需要从 Firebase 存储中获取数据。但是,我在尝试访问资源时遇到了 CORS(跨域资源共享)问题。这是我收到的错误消息:
任何关于如何解决此 CORS 问题的见解或建议将不胜感激!谢谢你。
if (user) {
const filePath = `users/${user.uid}/circuits/circuit.json`;
const storageRef = firebase.storage().ref(filePath);
storageRef.getDownloadURL()
.then((url) => {
console.log(url); // logs the URL
fileManager.loadFile(url); // when I try to load the file I get the CORS error
})
.catch((error) => {
console.error('Error getting download URL:', error);
});
} else {
console.error('User is not authenticated.');
}
我尝试将请求模式设置为“no-cors”,但它没有解决问题,我相信这不是推荐的解决方案。