const express = require("express"); // 获取启动参数 const { port } = require("./config"); const app = express(); var path = require("path"); app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use("/static", express.static(path.join(__dirname, "static"))); app.all("*", function (req, res, next) { res.header("Access-Control-Allow-Origin", "*"); res.header("Access-Control-Allow-Headers", "X-Requested-With"); res.header("Access-Control-Allow-Methods", "PUT,POST,GET,DELETE,OPTIONS"); res.header("X-Powered-By", " 3.2.1"); res.header("Content-Type", "application/json;charset=utf-8"); next(); }); //配置路由路径 app.use("/user", require("./routes/user")); app.use("/ingredient", require("./routes/ingredient")); app.use("/menu", require("./routes/menu")); app.listen(port, () => { console.log(`express server listen at http://localhost:${port}`); });