【问题标题】:Setting Google Cloud Storage access-control-allow-origin header still couldn't work设置 Google Cloud Storage access-control-allow-origin 标头仍然无法正常工作
【发布时间】:2021-09-15 13:09:43
【问题描述】:

在我的 json 文件中设置 cors 配置后,我仍然不断收到错误响应,以下是我的配置和响应。拜托,需要你的帮助,我已经为此奋斗了好几天。

[
   {
    "origin": ["*"],
    "responseHeader": ["X-Requested-With", "Access-Control-Allow-Origin", "Content-Type"],
    "method": ["GET", "HEAD", "DELETE", "OPTIONS"],
    "maxAgeSeconds": 3600
   }
]

这是我的 fetch api:

fetch('https://storage.googleapis.com/bucketName/photos/608d04ab0d1bd21fb4e94876/02-07-2021/SGNArtboard-1[751].png')
    .then(function(response) {
      return response.blob()
    })
    .then(function(blob) {
      console.log('blob : ', blob)
    });

这是我的错误回复:

Access to fetch at 'https://storage.googleapis.com/bucketName/photos/608d04ab0d1bd21fb4e94876/02-07-2021/SGNArtboard-1[751].png' from origin 'http://localhost:3000' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

【问题讨论】:

    标签: node.js reactjs google-cloud-platform frontend next.js


    【解决方案1】:

    我真的不知道发生了什么,但突然之间它开始正常工作,但这是我目前的配置,以防万一......

       [
         {
            "origin": ["http://localhost:3000"],
            "responseHeader": ["X-Requested-With", "Access-Control-Allow-Origin", "Content-Type"],
            "method": ["GET", "HEAD", "DELETE", "OPTIONS"],
            "maxAgeSeconds": 3600
          }
       ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-09-10
      • 2018-01-24
      • 2013-04-08
      • 2021-12-02
      • 1970-01-01
      • 1970-01-01
      • 2016-07-21
      • 2020-11-17
      相关资源
      最近更新 更多