生成会话后,它将回到前端(Vue组件),然后再次进入后端(Node JS)。与此同时,会话突然丢失。
我在CORS({})中更改了一点代码 嗯 客户= http://localhost:8080 服务器= http://localhost:4040 两者是分开的。
Api.JS
从“ axios”导入axios
导出默认()=> { 返回axios.create({ baseURL:“ http://localhost:4040”, 凭据:真实 }) }
App.vue
<script>
import LoginService from "@/services/LoginService";
export default {
name: "app",
components: {
modal
},
data() {
return {
firstname: ""
};
},
methods: {
async getAuth() {
const response = await LoginService.getAuth();
if (response.data.success) {
this.firstname = response.data.profile.firstname;
} else {
this.firstname = "";
}
}
},
beforeUpdate() {
this.getAuth();
}
};
</script>
LoginService
import Api from '@/services/Api'
export default {
getAuth() {
return Api().get('auth/getAuth');
}
}
有什么方法可以防止会话终止,它会在后端捕获吗?