After axios configures token information in header, a request from the backend will report a cross-domain problem. But there's nothing wrong with testing with postman.

as shown in the figure

clipboard.png

clipboard.png

//axios 
import axios from "axios"
axios.defaults.withCredentials = true;  //
const service=axios.create({
    baseURL:`${base}${itempath}`,
    timeout:5000
})
service.interceptors.request.use(
    config=>{
        if(store.getters.token){
            config.headers={
                "token":getToken(),
                "Accept":"application/json",
                "Content-Type":"application/json;charset=UTF-8"
            }
        }
        return config;
    },
    error=>{
        console.log(error);
        Promise.reject(error);
    }
)

the backend is also cross-domain, which can be requested normally before.

Mar.31,2022

token is a non-standard header, which requires the backend to output Access-Control-Allow-Origin headers in header. In addition, there is no cross-domain problem in the request in postman. Only


can you post a screenshot of the backend code

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-1b39521-2b9cf.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-1b39521-2b9cf.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?