Fixed api endpoints
All checks were successful
Build and Deploy Nuxt / build (push) Successful in 54s

This commit is contained in:
2026-05-02 16:53:15 +02:00
parent ee553eae82
commit b0509818b2
3 changed files with 7 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ const path = require('path');
const dotenv = require('dotenv'); const dotenv = require('dotenv');
if(process.env.NODE_ENV) { if(process.env.NODE_ENV) {
console.log(`.env.${process.env.NODE_ENV}`);
dotenv.config({ dotenv.config({
path: `.env.${process.env.NODE_ENV}` path: `.env.${process.env.NODE_ENV}`
}); });
@@ -20,7 +21,7 @@ const connectDB = require("./db");
// PUBLIC // PUBLIC
const uploadDir = path.join(__dirname, 'uploads'); const uploadDir = path.join(__dirname, 'uploads');
app.use('/public', express.static(uploadDir)); app.use('/api/public', express.static(uploadDir));
// JSON LIMIT EXPRESS // JSON LIMIT EXPRESS
app.use(express.json({ limit: '50mb' })); app.use(express.json({ limit: '50mb' }));
@@ -45,15 +46,15 @@ app.use(cors({
})); }));
// ROUTES (NO AUTH) // ROUTES (NO AUTH)
app.use('/user', require('./routes/user')); app.use('/api/user', require('./routes/user'));
// AUTH // AUTH
checkAuth = passport.authenticate('jwt', { session: false }); checkAuth = passport.authenticate('jwt', { session: false });
app.use(checkAuth); app.use(checkAuth);
// ROUTES WITH AUTH // ROUTES WITH AUTH
app.use('/campaign', require('./routes/campaign')); app.use('/api/campaign', require('./routes/campaign'));
app.use('/note', require('./routes/note')); app.use('/api/note', require('./routes/note'));
/* /*
app.use('/campaign', require('./routes/campaign')); app.use('/campaign', require('./routes/campaign'));
app.use('/maps', require('./routes/map')); app.use('/maps', require('./routes/map'));

View File

@@ -21,7 +21,7 @@ function retrieveAvatar(){
Server().get('/user/retrieve-avatar?username=' + GetUser().username) Server().get('/user/retrieve-avatar?username=' + GetUser().username)
.then((response) => { .then((response) => {
if(response.data.image){ if(response.data.image){
const imgUrl = backendUrl + "public/" + response.data.image; const imgUrl = backendUrl + "/public/" + response.data.image;
// Wait for the image to fully load // Wait for the image to fully load
const img = new Image(); const img = new Image();

View File

@@ -1,6 +1,4 @@
const backendUrl = process.env.API_BASE_URL || 'http://localhost:5000/api'
const config = useRuntimeConfig()
const backendUrl = config.public.apiBaseUrl
export { export {
backendUrl backendUrl