This commit is contained in:
parent
ce828cd5ef
commit
73063edd3f
1 changed files with 7 additions and 1 deletions
|
@ -9,7 +9,8 @@ const port = 8090;
|
||||||
// CORS aktivieren und den Origin explizit setzen
|
// CORS aktivieren und den Origin explizit setzen
|
||||||
app.use(cors({
|
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',
|
origin: 'http://127.0.0.1:8080',
|
||||||
|
//origin: 'https://192-168-197-2.c-one-infra.de',
|
||||||
methods: ['GET', 'POST', 'OPTIONS'], // Zulässige Methoden
|
methods: ['GET', 'POST', 'OPTIONS'], // Zulässige Methoden
|
||||||
allowedHeaders: ['Content-Type'], // Zulässige Header
|
allowedHeaders: ['Content-Type'], // Zulässige Header
|
||||||
credentials: true // Falls du Cookies oder Auth-Daten senden möchtest
|
credentials: true // Falls du Cookies oder Auth-Daten senden möchtest
|
||||||
|
@ -21,6 +22,11 @@ app.options('/api/command', cors()); // für eine bestimmte Route
|
||||||
// Verwende die Middleware, um POST-Body als JSON zu lesen
|
// Verwende die Middleware, um POST-Body als JSON zu lesen
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
console.log('CORS headers set');
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
app.post('/api/command', (req, res) => {
|
app.post('/api/command', (req, res) => {
|
||||||
executeCommand();
|
executeCommand();
|
||||||
res.status(200).send('Command executed\n');
|
res.status(200).send('Command executed\n');
|
||||||
|
|
Loading…
Reference in a new issue