// server.mjs — LOKUTOR_API_KEY stays on the server
import express from 'express';
const app = express();
app.post('/api/lokutor-ticket', requireSignedInUser, async (req, res) => {
const r = await fetch('https://api.lokutor.com/ws-ticket', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.LOKUTOR_API_KEY}` },
});
if (!r.ok) return res.status(502).json({ error: 'could not get a ticket' });
const { ticket, expires_in } = await r.json();
res.json({ ticket, expires_in });
});
function requireSignedInUser(req, res, next) {
// Replace with your own session check.
next();
}
app.listen(3000);