V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
dog
V2EX  ›  问与答

又拍云的表单 API 不支持通过 ajax 跨域调用吗?

  •  1
     
  •   dog · 2019-05-29 19:17:16 +08:00 · 1913 次点击
    这是一个创建于 1765 天前的主题,其中的信息可能已经有所发展或是发生改变。

    用 ajax 上传文件,返回 400 错误,提示:

    Access to XMLHttpRequest at 'https://v0.api.upyun.com/xxx' from origin 'https://xxxxx' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

    难道这个接口只能用 HTML 的 form 提交?不能 ajax 调用?

    2 条回复    2019-05-30 02:24:02 +08:00
    phy25
        2
    phy25  
       2019-05-30 02:24:02 +08:00
    应该是支持的哦。需要检查一下你的代码和浏览器环境呢。

    Request URL: https://v0.api.upyun.com/repo
    Request Method: OPTIONS
    Status Code: 200
    Remote Address: 204.237.243.107:443
    Referrer Policy: no-referrer-when-downgrade
    access-control-allow-headers: Authorization, Content-Type, X-Date, Folder
    access-control-allow-methods: PUT, GET, POST, HEAD, OPTIONS, DELETE
    access-control-allow-origin: *
    content-type: application/octet-stream
    date: Wed, 29 May 2019 18:20:24 GMT
    server: marco/2.10
    status: 200
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4180 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 05:28 · PVG 13:28 · LAX 22:28 · JFK 01:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.