Second test
Some checks failed
Build and Deploy Nuxt / build (push) Failing after 9s

This commit is contained in:
2026-05-02 17:17:21 +02:00
parent 50b3e421df
commit 306dd8cabc
4 changed files with 16 additions and 11 deletions

View File

@@ -1,5 +0,0 @@
const backendUrl = import.meta.env.NUXT_PUBLIC_API_BASE_URL || 'http://localhost:5000/api'
export {
backendUrl
};

View File

@@ -1,13 +1,16 @@
import axios from 'axios';
const server = axios.create({
baseURL: import.meta.env.NUXT_PUBLIC_API_BASE_URL || 'http://localhost:5000/api',
baseURL: 'http://localhost:5000/api', // fallback only
headers: {
"Access-Control-Allow-Origin": "*",
}
});
// Attach token dynamically on each request via interceptor
export const initApi = (baseURL: string) => {
server.defaults.baseURL = baseURL;
};
server.interceptors.request.use((config) => {
const token = localStorage.getItem('token');
if (token) {
@@ -16,4 +19,6 @@ server.interceptors.request.use((config) => {
return config;
});
export default () => server;
export default () => server;
export const getBaseUrl = () => server.defaults.baseURL;