代码拉取完成,页面将自动刷新
同步操作将从 N0ts/GiteeApi 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
/*
* @Author: N0ts
* @Date: 2022-10-10 14:31:20
* @Description: main
* @FilePath: /gitee-api/main.js
* @Mail:mail@n0ts.cn
*/
// 创建 express & 服务器
const express = require("express");
const app = express();
// post 请求需要
app.use(express.json());
// config
const config = require("./config/config");
// 跨域配置
app.all("*", (req, res, next) => {
try {
// google需要配置,否则报错cors error
res.setHeader("Access-Control-Allow-Credentials", "true");
// 允许的地址,http://127.0.0.1:9000这样的格式
res.setHeader("Access-Control-Allow-Origin", req.get("Origin"));
// 允许跨域请求的方法
res.setHeader(
"Access-Control-Allow-Methods",
"POST, GET, OPTIONS, DELETE, PUT"
);
// 允许跨域请求header携带哪些东西
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept, If-Modified-Since"
);
} catch {
return next();
}
next();
});
// 导入路由
app.use(require("./router/router"));
// 监听端口
app.listen(config.port, function () {
console.log(`服务已启动:http://localhost:${config.port}`);
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。