add http-server part 7.9.8 CORS
All checks were successful
ci / build (push) Successful in 1m21s

This commit is contained in:
Christopher Hase 2025-04-11 13:37:26 +02:00
parent 85eb8470f5
commit ce828cd5ef

View file

@ -8,7 +8,8 @@ const port = 8090;
//app.use(cors());
// CORS aktivieren und den Origin explizit setzen
app.use(cors({
origin: 'http://localhost:8080', // Erlaubt Anfragen vom Frontend (localhost:8080)
//origin: 'http://localhost:8080', // Erlaubt Anfragen vom Frontend (localhost:8080)
origin: 'https://192-168-197-2.c-one-infra.de',
methods: ['GET', 'POST', 'OPTIONS'], // Zulässige Methoden
allowedHeaders: ['Content-Type'], // Zulässige Header
credentials: true // Falls du Cookies oder Auth-Daten senden möchtest
@ -20,8 +21,6 @@ app.options('/api/command', cors()); // für eine bestimmte Route
// Verwende die Middleware, um POST-Body als JSON zu lesen
app.use(express.json());
app.post('/api/command', (req, res) => {
executeCommand();
res.status(200).send('Command executed\n');