Compare commits

...

4 Commits

Author SHA1 Message Date
15107cdc63 removed routing 2025-10-22 23:31:38 +02:00
22266c765b api endpoints changed 2025-10-22 22:21:44 +02:00
a66609a40c pm2 not in home directory -> /app/ 2025-10-22 21:57:26 +02:00
87dda38bc3 updated user to have a home laufwerk 2025-10-22 21:42:47 +02:00
5 changed files with 22 additions and 25 deletions

View File

@@ -71,12 +71,15 @@ COPY --from=frontend-builder /app/frontend/build/ ./frontend-build/
COPY ecosystem.config.cjs ./
# Create a non-root user and group - DEBIAN STYLE
RUN groupadd -r -g 1001 nodejs && \
useradd -r -u 1001 -s /bin/bash -g nodejs schichtplan && \
RUN groupadd -g 1001 nodejs && \
useradd -m -u 1001 -s /bin/bash -g nodejs schichtplan && \
chown -R schichtplan:nodejs /app && \
chmod 755 /app && \
chmod 775 /app/data
# Set PM2 to use app directory instead of home directory
ENV PM2_HOME=/app/.pm2
USER schichtplan
EXPOSE 3000 3002

View File

@@ -1,6 +1,7 @@
// backend/src/server.ts
import express from 'express';
import cors from 'cors';
import { fileURLToPath } from 'url';
import path from 'path';
import { initializeDatabase } from './scripts/initializeDatabase.js';
// Route imports
@@ -11,13 +12,18 @@ import setupRoutes from './routes/setup.js';
import scheduledShifts from './routes/scheduledShifts.js';
import schedulingRoutes from './routes/scheduling.js';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const app = express();
const PORT = 3002;
// CORS und Middleware
app.use(cors());
// Middleware
app.use(express.json());
// Serviere statische Frontend-Dateien
app.use(express.static(path.join(__dirname, '../../frontend-build')));
// API Routes
app.use('/api/setup', setupRoutes);
app.use('/api/auth', authRoutes);

View File

@@ -2,7 +2,7 @@
module.exports = {
apps: [
{
name: 'backend',
name: 'schichtplaner',
script: './dist/server.js',
instances: 1,
exec_mode: 'fork',
@@ -10,21 +10,8 @@ module.exports = {
NODE_ENV: 'production',
PORT: 3002
},
error_file: './logs/backend-err.log',
out_file: './logs/backend-out.log',
time: true
},
{
name: 'frontend',
script: 'npx',
args: 'serve -s frontend-build -l 3000',
instances: 1,
exec_mode: 'fork',
env: {
NODE_ENV: 'production'
},
error_file: './logs/frontend-err.log',
out_file: './logs/frontend-out.log',
error_file: './logs/app-err.log',
out_file: './logs/app-out.log',
time: true
}
]

View File

@@ -20,6 +20,7 @@ interface AuthContextType {
}
const AuthContext = createContext<AuthContextType | undefined>(undefined);
const API_BASE_URL = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api';
interface AuthProviderProps {
children: ReactNode;
@@ -48,7 +49,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
const checkSetupStatus = async (): Promise<void> => {
try {
console.log('🔍 Checking setup status...');
const response = await fetch('http://localhost:3002/api/setup/status');
const response = await fetch(`${API_BASE_URL}/setup/status`);
if (!response.ok) {
throw new Error('Setup status check failed');
}
@@ -72,7 +73,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
return;
}
const response = await fetch('http://localhost:3002/api/auth/me', {
const response = await fetch(`${API_BASE_URL}/auth/me`, {
headers: {
'Authorization': `Bearer ${token}`
}
@@ -104,7 +105,7 @@ export const AuthProvider: React.FC<AuthProviderProps> = ({ children }) => {
try {
console.log('🔐 Attempting login for:', credentials.email);
const response = await fetch('http://localhost:3002/api/auth/login', {
const response = await fetch(`${API_BASE_URL}/auth/login`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',

View File

@@ -1,6 +1,6 @@
// frontend/src/services/authService.ts
import { Employee } from '../models/Employee';
const API_BASE = 'http://localhost:3002/api';
const API_BASE = process.env.REACT_APP_API_BASE_URL || 'http://localhost:3002/api';
export interface LoginRequest {
email: string;