Options method access

post-data
Bastien OLLIER 1 year ago
parent d7af207b06
commit 4987904060

@ -15,6 +15,14 @@ const generateId = () => nanoid(32);
const clients: Record<string, http.ServerResponse> = {}; const clients: Record<string, http.ServerResponse> = {};
const server = http.createServer((req, res) => { const server = http.createServer((req, res) => {
if (req.method === 'OPTIONS') {
res.writeHead(200, {
'Acess-Control-Allow-Methods': '*',
'Acess-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': process.env.ALLOW_ORIGIN || '*',
});
return;
}
switch (req.url) { switch (req.url) {
case '/run': case '/run':
const jobId = generateId(); const jobId = generateId();

Loading…
Cancel
Save