implemented authentication with sidebase/nuxt-auth

This commit is contained in:
Johanna Kuehner
2024-03-11 18:19:11 +01:00
parent 7c19ee9215
commit 6d6b36bdd9
34 changed files with 12861 additions and 2097 deletions

View File

@ -1,14 +1,30 @@
import axios from 'axios';
import axios, {AxiosError} from 'axios';
import clientsideConfig from './clientsideConfig'
//create axios instance
const Axios = axios.create({
// baseURL: `https://${serversideConfig.url}:${serversideConfig.port}`,
//baseURL: `https://${serversideConfig.url}:${serversideConfig.port}/`,
baseURL: `https://${clientsideConfig.url}:${clientsideConfig.port}/`,
headers: {
// 'Accept': 'application/json',
'Content-Type': 'application/json',
//Authorization: `Bearer`,
Accept: "*",
},
withCredentials: true,
credentials: true,
})
Axios.interceptors.response.use((response) => response, (error) => {
if (error instanceof AxiosError) {
console.error('Status: ', error.response?.status, '\nHeaders: '. error.response?.headers, '\nMessage: '. error.response?.data.message)
} else { console.error('Error: ', error); };
if (error.response?.status === 403) { window.location.href = '/login'; };
return Promise.reject(error);
});
export default Axios;