Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
wh469012917
V2EX  ›  云计算

谷歌云存储该如何设置允许跨域访问?

  •  
  •   wh469012917 · Feb 25, 2020 · 4987 views
    This topic created in 2285 days ago, the information mentioned may be changed or developed.
    如题, 根据谷歌云的文档, 提示设置成功了,但是发起请求依然提示跨域, 网络上的方案全部试过了, 全都无效
    10 replies    2020-02-27 20:32:18 +08:00
    whileFalse
        1
    whileFalse  
       Feb 25, 2020
    头像这个小姐姐好亲切 是哪位
    DGideas
        2
    DGideas  
       Feb 25, 2020
    https://cloud.google.com/storage/docs/cross-origin

    看一下响应头是否有 CORS 标头呢?
    wh469012917
        3
    wh469012917  
    OP
       Feb 25, 2020
    @DGideas 看了请求, 没有响应跨域相关的头, 但是通过 gsutil 去 get cors 配置, 确实是配置好了
    DGideas
        4
    DGideas  
       Feb 25, 2020
    @wh469012917 发个 ticket 问问吧
    wh469012917
        5
    wh469012917  
    OP
       Feb 25, 2020
    @DGideas 咋发?找了半天没找到工单在哪里
    crystom
        7
    crystom  
       Feb 25, 2020
    可能是浏览器对非跨域请求做了缓存了,导致后面即使有 Origin 也不行
    wh469012917
        8
    wh469012917  
    OP
       Feb 26, 2020
    @crystom 不是的, 换浏览器换电脑, 都是一样的结果
    crystom
        9
    crystom  
       Feb 26, 2020
    @wh469012917 我说的缓存指的是,浏览器进行非跨域请求时,没返回跨域头。后面浏览器又进行跨域请求时,就会报错。你提供的信息太少了,至少也给个对象的链接吧
    wh469012917
        10
    wh469012917  
    OP
       Feb 27, 2020
    @crystom
    这个是其中一个资源链接, 控制台上传, 不是 api 上传的:
    https://storage.googleapis.com/drivefile/1uj4wzb0qj5wrjgyt4tzm009o.jpeg

    这是通过 gsutil 设置的 cors 的配置:
    ```
    wenghang1228@cloudshell:~ (lustrous-camera-267010)$ gsutil cors get gs://drivefile
    [{"maxAgeSeconds": 360, "method": ["GET", "POST", "PUT", "HEAD", "DELETE"], "origin": ["http://127.0.0.1:8081"], "responseHeader": ["Access-Control-Allow-Origin"]
    }]
    ```
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2936 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 02:18 · PVG 10:18 · LAX 19:18 · JFK 22:18
    ♥ Do have faith in what you're doing.