How does the iview Upload component achieve cross-domain file upload?

upload iview upload components

problem description

there is no problem with other interfaces. Cross-domain header has been set up on the server side and other ajax request interfaces are running normally, but the upload of upload component files will prompt cross-domain problems

related code error prompt

Access to XMLHttpRequest at" http://149.60.61.206/api/v1/u..." from origin" http://localhost:8081" has been blocked by CORS policy: Response to preflight request doesn"t pass access control check: Redirect is not allowed for a preflight request.

Code

 <Upload
       type="drag"
       name="imgs"
       :action="uploadUri"
       :on-success="handleUploadSuccess"
       :with-credentials="true"
       :headers=headers
       :format="["jpg","jpeg","png","gif"]"
       >
    <div style="padding: 20px 0">
         <Icon type="ios-cloud-upload" size="52" style="color: -sharp3399ff"></Icon>
         

</div> </Upload>
 uploadUri:this.$baseUri+"api/v1/uploader/imageUpload/",
 headers:{"Access-Control-Allow-Origin":"*"},
May.27,2022

clipboard.png
because you set this to true, he will carry cookie credential information
for requests with identity credentials, the server must not set the value of Access-Control-Allow-Origin to "". This is because the Cookie information is carried in the header of the request. If the value of Access-Control-Allow-Origin is "", the request will fail.
that is, when Access-Control-Allow-Credentials is set to true,
Access-Control-Allow-Origin cannot be set to *


has it been solved?

Menu