V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Recommended Services
Amazon Web Services
LeanCloud
New Relic
ClearDB
wh469012917
V2EX  ›  云计算

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

  •  
  •   wh469012917 · 2020-02-25 16:17:09 +08:00 · 4028 次点击
    这是一个创建于 1494 天前的主题,其中的信息可能已经有所发展或是发生改变。
    如题, 根据谷歌云的文档, 提示设置成功了,但是发起请求依然提示跨域, 网络上的方案全部试过了, 全都无效
    10 条回复    2020-02-27 20:32:18 +08:00
    whileFalse
        1
    whileFalse  
       2020-02-25 17:07:54 +08:00
    头像这个小姐姐好亲切 是哪位
    DGideas
        2
    DGideas  
       2020-02-25 17:29:39 +08:00
    https://cloud.google.com/storage/docs/cross-origin

    看一下响应头是否有 CORS 标头呢?
    wh469012917
        3
    wh469012917  
    OP
       2020-02-25 17:42:41 +08:00
    @DGideas 看了请求, 没有响应跨域相关的头, 但是通过 gsutil 去 get cors 配置, 确实是配置好了
    DGideas
        4
    DGideas  
       2020-02-25 17:56:22 +08:00
    @wh469012917 发个 ticket 问问吧
    wh469012917
        5
    wh469012917  
    OP
       2020-02-25 18:03:55 +08:00
    @DGideas 咋发?找了半天没找到工单在哪里
    DGideas
        6
    DGideas  
       2020-02-25 19:37:22 +08:00
    crystom
        7
    crystom  
       2020-02-25 22:39:18 +08:00
    可能是浏览器对非跨域请求做了缓存了,导致后面即使有 Origin 也不行
    wh469012917
        8
    wh469012917  
    OP
       2020-02-26 07:59:50 +08:00
    @crystom 不是的, 换浏览器换电脑, 都是一样的结果
    crystom
        9
    crystom  
       2020-02-26 09:07:28 +08:00
    @wh469012917 我说的缓存指的是,浏览器进行非跨域请求时,没返回跨域头。后面浏览器又进行跨域请求时,就会报错。你提供的信息太少了,至少也给个对象的链接吧
    wh469012917
        10
    wh469012917  
    OP
       2020-02-27 20:32:18 +08:00
    @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"]
    }]
    ```
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2740 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:34 · PVG 20:34 · LAX 05:34 · JFK 08:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.