[Solved] cookie loss when uploading components using the elementui framework El upload

The background uses El upload to complete the upload. Sometimes it is found that the upload cannot succeed and will be redirected to the login page.

The check found that the URL request did not add a cookie request, and the cookie was missing, so the verification could not be completed.

The default request of El upload component is without cookie

set the attribute with credentials to true. It supports sending cookie credential information (: with credentials =’true ‘)

If you follow the above method, the problem still exists, which may be caused by the existence of a virtual directory on your website.

The URL address assigned to the action of El upload must be the complete root directory path (/ virtual directory name/uploaded URL address)

It is emphasized here that the virtual directory name should be the same as the virtual directory name when you store cookies. It is recommended to keep the case consistent

         <el-button size="small" type="primary">choose the files</el-button>
         <div slot="tip" class="el-upload__tip"></div>

Similar Posts: