Upload is not working in localhost Component:Upload
See original GitHub issueVersion
antd 3.2.0 dva 2.0.3
Environment
Mac OS High Sierra 10.13.3, Chrome version 64.0.3282.140 Node v6.9.1 npm v5.6.0
Reproduction link
https://codesandbox.io/s/q4l788znkw
Steps to reproduce
Start platform using npm run start:no-proxy. (I configured my no-proxy url in, roadhogrc.mock.js and it’s working for all the other api calls) Upload small image file.
What is expected?
It is expected to receive the file in my API service.
What is actually happening?
I checked my API service and it’s working calling upload file from a different place, but when I call it from my web built with ant design, using Upload component, Upload shows headers and request body correctly, but my API receive no files.
my code:
<Upload
action="/api/upload_file"
listType="picture-card"
showUploadList={{ showPreviewIcon: false }}
headers={{
Authorization: `Bearer 'token'`,
}}
name="file"
withCredentials
>
<Icon type="plus" />
<div className="ant-upload-text">Upload</div>
</Upload>
Request general:
Request URL: http://localhost:8000/api/upload_file Request Method: POST
Request headers:
Accept: */* Accept-Encoding: gzip, deflate, br Accept-Language: en-US,en;q=0.9,es;q=0.8 Authorization: Bearer f3618115e76f934934983ehn9RvpoN5ohGjrOoBm9E3LA9OeZbiJW Connection: keep-alive Content-Length: 9815 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryrNrG4oEpcIkf8gp4 Host: localhost:8000 Origin: http://localhost:8000 Referer: http://localhost:8000/messages/new User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) > Chrome/64.0.3282.140 Safari/537.36 X-Requested-With: XMLHttpRequest
Request payload is:
------WebKitFormBoundaryrNrG4oEpcIkf8gp4 Content-Disposition: form-data; name=“file”; filename=“Trenes_de_Buenos_Aires_Logo.png” Content-Type: image/png
------WebKitFormBoundaryrNrG4oEpcIkf8gp4–
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (5 by maintainers)
Top GitHub Comments
Hey, Any solution for this issue?
@zhuozp No, it is working on production but it doesn’t work on localhost. It seems to be a bug on roadhog as @yesmeck said, because it’s everything the same between production and localhost, but in localhost we use proxy defined in .roadhog.mock.js (not the mock api but a locahost url). I don’t know can we solve this problem. If you find a solution please let me know.