fix cors wonkiness
This commit is contained in:
parent
46906f8900
commit
8fd7bfa6cf
3 changed files with 28 additions and 4 deletions
8
index.js
8
index.js
|
@ -2,11 +2,13 @@ import { spawn } from "node:child_process";
|
|||
import { mkdir } from 'node:fs/promises';
|
||||
import { createHash } from "node:crypto";
|
||||
import express from "express";
|
||||
import cors from "cors";
|
||||
|
||||
let sessions = {};
|
||||
let channels = {};
|
||||
|
||||
const app = express();
|
||||
app.use(cors())
|
||||
app.use(express.json())
|
||||
app.set('trust proxy', true)
|
||||
|
||||
|
@ -35,7 +37,7 @@ app.post('/', async function (req, res) {
|
|||
if (channels[id].headersSent) return;
|
||||
|
||||
try {
|
||||
channels[id].send(str).header('access-allow-control-origin', '*')
|
||||
channels[id].send(str)
|
||||
} catch (err) { }
|
||||
}
|
||||
});
|
||||
|
@ -51,7 +53,7 @@ app.post('/', async function (req, res) {
|
|||
if (fsession != channels[id]) return;
|
||||
if (channels[id].headersSent) return;
|
||||
try {
|
||||
channels[id].send('Input is possibly malformed.').header('access-allow-control-origin', '*')
|
||||
channels[id].send('Input is possibly malformed.')
|
||||
} catch (err) {
|
||||
|
||||
}
|
||||
|
@ -65,10 +67,8 @@ app.post('/', async function (req, res) {
|
|||
msg = `/${msg.slice(1)}`;
|
||||
}
|
||||
|
||||
setTimeout(async function () {
|
||||
sessions[id].lastBusy = new Date();
|
||||
sessions[id].stdin.write(msg + '\n');
|
||||
}, 100);
|
||||
});
|
||||
|
||||
app.listen(process.env.port || 3007)
|
Loading…
Add table
Add a link
Reference in a new issue