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

<Upload action="/sys/mts/uploadFile"
                :headers="headers"
                :with-credentials= true
                :before-upload="handleUpload"
                :show-upload-list="showUploadList"
                style="margin-left: 131px; margin-top: -30px;"
        ></Upload>

related content add:

 headers: {
    "Access-Control-Allow-Origin" : "*"
},
credentials: true

Thank you, bosses!

Mar.20,2021

have you solved it? I have also encountered this situation


'Access-Control-Allow-Origin':' *' it is useless to set the foreground in the background, but it will turn the request into a non-simple request


.

Cross-domain file upload is actually a cross-domain request. If you are a project generated by vue-cli, under the config file, find index.js, to configure cross-domain configuration. For example:

proxyTable: {
      '/api': {
        target: '',      
        changeOrigin: true,
        pathRewrite: {
          '^/api': '',
        },
      }
    },

when requesting, add / api/ your interface name in front of all interfaces to achieve cross-domain.


it's no use setting headers at the front end. You can either set ``Access-Control-Allow-Origin':'*' on the backend, or set the proxy in the proxyTable in config/index.js. Of course, setting the proxy is only useful for development.


setting the proxy is also useless. Why?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1c24534-336e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1c24534-336e2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?