Cloud Functions on EdgeOne Pages - Express

Cloud Functions allow you to run code in the Node.js Runtime without managing servers. With its capabilities, you can easily develop and deploy full-stack applications based on the Express framework on Pages.

./cloud-functions/express/[[default]].js

import express from "express";
const app = express();

// Add logging middleware
app.use((req, res, next) => {
  console.log(`[Log] ${req.method} ${req.url}`);
  next();
});

// Add root route handling
app.get("/", (req, res) => {
  res.json({ message: "Hello from Express on Cloud Functions!" });
});

// Export the handling function
export default app;