import { Router } from "@fastly/expressly";
const backend = "origin_0";
const router = new Router();
let backendResponse;
// Configure middleware that runs on all requests.
router.use(async (req, res) => {
// Avoid making changes to the original Request object -
// Clone and create a new object instead.
const newReq = new Request(req, {
// If the method is PUT change it to POST
method: req.method === "PUT" ? "POST" : req.method,
});
// Send the backend response to the client.
res.send(await fetch(newReq, { backend }));
});
router.listen();