Vue axios config is configured to explain why it is still cross-domain.

proxyTable: {
      "/api": { //"/api""http://f.apiplus.c" 
        target: "http://127.0.0.1:3000", // 
        changeOrigin: true, // 
        pathRewrite: {
          "^/api": "" // 
        }
      }
    },
    


export const getHomeCasual = ()=>ajax("api/homecasual");
Mar.23,2022

1. First of all, the cross-domain of the web end is caused by the security policy of the browser. To solve the cross-domain problem, the server needs to support
2. The server needs to set the following response header in the response header
clipboard.png

.

wherein:
origin allows cross-domain sources. Take origin
credentials in the request header to allow cross-domain credentials (such as cookie, other certificates, etc.)
methods allows cross-domain methods, generally get,post (axios initiates pre-request option for miscellaneous requests)
header allows cross-domain request headers


is / api/homecasual instead of api/homecasual , you are missing a / .

proxyTable: {
      '/api': { //"/api""http://f.apiplus.c" 
        target: 'http://127.0.0.1:3000', // 
        changeOrigin: true, // 
        pathRewrite: {
          '^/api': '' // 
        }
      }
    },
    
export const getHomeCasual = ()=>ajax('/api/homecasual');
Menu