problem description
after using vue-element-admin, the page is finished now, but there is a problem with requesting the backend interface. I generally know whether to configure proxy, but it still doesn"t work. There is no way of thinking at present. For advice, thank you
config/index.js configuration
proxyTable: {
"/student": {
target: "http://192.168.0.79:8080",
pathRewrite: {
"^/student": "/student"
},
// changeOrigin: true
}
},
config/dev.env.js configuration
module.exports = {
NODE_ENV: ""development"",
ENV_CONFIG: ""dev"",
BASE_API: ""http://192.168.0.79:8080""
}
request function
export function uploadExcel() {
return request({
url: "/student/importStudent",
method: "post"
})
// return axios({
// method: "get",
// url: "/student/importStudent"
// // url: ""
// })
}
axios method
const service = axios.create({
baseURL: process.env.BASE_API, // api base_url
timeout: 5000 // request timeout
})
// request interceptor
service.interceptors.request.use(
config => {
// Do something before request is sent
if (store.getters.token) {
// token-- ["X-Token"]key
config.headers["X-Token"] = getToken()
// config.method = "post"
// config.headers["Access-Control-Allow-Origin"] = "*"
// config.headers["Access-Control-Allow-Methods"] = "PUT,GET,POST,OPTIONS"
// config.headers["Access-Control-Allow-Headers"] = "X-Requested-With, Content-Type, X-File-Name"
}
return config
},
error => {
// Do something with request error
console.log(error) // for debug
Promise.reject(error)
}
)
error prompt