[英]Firebase Storage CORS error in Vue.js and Nuxt.js
I am trying to download a.pdf stored on firebase-storage from my web application (Vue.js + Nuxt.js)我正在尝试从我的 web 应用程序(Vue.js + Nuxt.js)下载存储在 firebase-storage 上的 a.pdf
But got this error但是得到了这个错误
Access to fetch at 'https://firebasestorage.googleapis.com/v0/b/************o/chats%2F96U5ERFOmHBGswQhDhaR%2Fdc8c9b64-6bdb-4cd0-b0a9-f59e18f10113?alt=media' from origin 'https://example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
访问 'https://firebasestorage.googleapis.com/v0/b/************o/chats%2F96U5ERFOmHBGswQhDhaR%2Fdc8c9b64-6bdb-4cd0-b0a9-f59e18f10113?alt=media ' from origin 'https://example.com' 已被 CORS 策略阻止:请求的资源上不存在“Access-Control-Allow-Origin” header。 If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
如果不透明的响应满足您的需求,请将请求的模式设置为“no-cors”以获取禁用 CORS 的资源。
What I have tried so far is to install @nuxtjs/proxy and configure it like this:到目前为止,我尝试的是安装@nuxtjs/proxy并像这样配置它:
nuxt.config.js nuxt.config.js
proxy: ["https://firebasestorage.googleapis.com/v0/b/*************"],
modules:[
'@nuxtjs/proxy',
]
But error is still there但是错误仍然存在
You need to do the changes on firebase.您需要对 firebase 进行更改。
Just create a file cors.json只需创建一个文件 cors.json
[
{
"origin": [ "https://example.com" ],
"method": [ "GET" ],
"maxAgeSeconds": 3600
}
]
And upload it via gsutil (Windows)并通过 gsutil (Windows) 上传
gsutil cors set cors.json gs://<your bucket>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.