react-component / react-component/upload

使用antd的上传组件向oss上传文件的时候提示跨域

Open
#250 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
804
Forks
323
Avg merge
12m
Merged PRs (30d)
1

Description

使用的antd版本是3.19.5,上传的方法是服务器端签名,js直传
我可以确定的是oss是配置了允许跨域的,小程序可以通过我服务器段生成的签名,policy上传文件
oss提供的jssdk也是可以的,但是用antd的上传组件不行,一直提示跨域
Access to XMLHttpRequest at 'https://xxx.com/' from origin 'https://xxxxxx.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
具体代码如下

tmp

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the antd 3.19.5 upload flow using server-side signing and direct OSS upload. Inspect the upload component's request and preflight behavior against the reported CORS error, then compare it with the working OSS JavaScript SDK flow. Done means the signed upload completes without the browser blocking the preflight request.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.