FIX: Habilitar credenciales en axios
This commit is contained in:
parent
2ef554a2a8
commit
8d752979a7
5
src/pages/Examples/Index.vue
Normal file
5
src/pages/Examples/Index.vue
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<template>
|
||||||
|
<div class="p-2">
|
||||||
|
<h4>Rutas de ejemplo</h4>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
14
src/router/Examples.js
Normal file
14
src/router/Examples.js
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* Archivo de rutas de ejemplos.
|
||||||
|
*
|
||||||
|
* En producción se debe eliminar o comentar. Las vistas de ejemplo opcionalmente pueden ser eliminadas o
|
||||||
|
* dejadas como referencia.
|
||||||
|
*/
|
||||||
|
|
||||||
|
export default [
|
||||||
|
{
|
||||||
|
path: '/examples',
|
||||||
|
name: 'examples.index',
|
||||||
|
component: () => import('@Pages/Examples/Index.vue')
|
||||||
|
}
|
||||||
|
]
|
||||||
@ -1,6 +1,8 @@
|
|||||||
import { createRouter, createWebHashHistory } from 'vue-router'
|
import { createRouter, createWebHashHistory } from 'vue-router'
|
||||||
import { hasPermission } from '@Plugins/RolePermission';
|
import { hasPermission } from '@Plugins/RolePermission';
|
||||||
|
|
||||||
|
import examples from './Examples';
|
||||||
|
|
||||||
function can(next, can) {
|
function can(next, can) {
|
||||||
if (!hasPermission(can)) {
|
if (!hasPermission(can)) {
|
||||||
next({ name: '404' });
|
next({ name: '404' });
|
||||||
@ -128,7 +130,8 @@ const router = createRouter({
|
|||||||
path: '/:pathMatch(.*)*',
|
path: '/:pathMatch(.*)*',
|
||||||
name: '404',
|
name: '404',
|
||||||
component: () => import('@Pages/Errors/404.vue')
|
component: () => import('@Pages/Errors/404.vue')
|
||||||
}
|
},
|
||||||
|
...examples,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import axios from 'axios';
|
|||||||
import { reactive, ref } from 'vue';
|
import { reactive, ref } from 'vue';
|
||||||
|
|
||||||
axios.defaults.withXSRFToken = true;
|
axios.defaults.withXSRFToken = true;
|
||||||
// axios.defaults.withCredentials = true;
|
axios.defaults.withCredentials = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Códigos de falla
|
* Códigos de falla
|
||||||
@ -23,7 +23,7 @@ const failCodes = [
|
|||||||
/**
|
/**
|
||||||
* Servidor a utilizar
|
* Servidor a utilizar
|
||||||
*/
|
*/
|
||||||
const token = ref(localStorage.token);
|
const token = ref(sessionStorage.token);
|
||||||
const csrfToken = ref(localStorage.csrfToken);
|
const csrfToken = ref(localStorage.csrfToken);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,7 +31,7 @@ const csrfToken = ref(localStorage.csrfToken);
|
|||||||
*/
|
*/
|
||||||
const defineApiToken = (x) => {
|
const defineApiToken = (x) => {
|
||||||
token.value = x;
|
token.value = x;
|
||||||
localStorage.token = x;
|
sessionStorage.token = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -47,7 +47,7 @@ const defineCsrfToken = (x) => {
|
|||||||
*/
|
*/
|
||||||
const resetApiToken = () => {
|
const resetApiToken = () => {
|
||||||
token.value = undefined;
|
token.value = undefined;
|
||||||
localStorage.removeItem('token');
|
sessionStorage.removeItem('token');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user