import express from 'express'; import cors from 'cors'; import { executeCommand } from './broker.js'; const app = express(); const port = 8090; //CORS aktivieren app.use(cors()); // Füge dies hinzu, um die OPTIONS-Anfragen korrekt zu behandeln app.options('*', cors()); // Verwende die Middleware, um POST-Body als JSON zu lesen app.use(express.json()); /*app.use(cors({ origin: 'http://localhost:8080' }));*/ app.post('/api/command', (req, res) => { executeCommand(); res.status(200).send('Command executed\n'); }); app.listen(port, '0.0.0.0', () => { console.log(`Server läuft auf http://0.0.0.0:${port}`); });