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

2019-05-29 19:17:16 +08:00
 dog

用 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 调用?

1943 次点击
所在节点    问与答
2 条回复
kingwrcy
2019-05-29 21:17:07 +08:00
用服务端调
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

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/568881

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX