|
@@ -87,6 +87,9 @@ router.get("/:record_id", async function (req, res) {
|
|
|
const record_id = req.params.record_id; // 获取 fileId 参数
|
|
|
const recordInfo = await getRecordInfoById(record_id)
|
|
|
const files = await getFileByRecordId(record_id)
|
|
|
+ // 获取请求的来源域名
|
|
|
+ // const host = req.headers['host']; // 主机名 + 端口
|
|
|
+ const origin = req.headers['origin']; // 请求的来源域(适用于跨域)
|
|
|
res.json({
|
|
|
code: 200,
|
|
|
data: {
|
|
@@ -94,7 +97,7 @@ router.get("/:record_id", async function (req, res) {
|
|
|
"time": shanghaiTimeFormat(recordInfo.time, 'YYYY-MM-DD'),
|
|
|
"create_time": shanghaiTimeFormat(recordInfo.create_time),
|
|
|
"update_time": shanghaiTimeFormat(recordInfo.update_time),
|
|
|
- files: files.map(elm =>`http://127.0.0.1:3000/api/v1/files/${elm.file_id}`)
|
|
|
+ files: files.map(elm =>`${origin}/api/v1/files/${elm.file_id}`)
|
|
|
}
|
|
|
});
|
|
|
});
|
|
@@ -118,9 +121,7 @@ router.get("/about", function (req, res) {
|
|
|
router.get("/:book_id/:time", async function (req, res) {
|
|
|
const time = req.params.time; // 获取 fileId 参数
|
|
|
const book_id = req.params.book_id; // 获取 fileId 参数
|
|
|
- console.log(120, time, book_id);
|
|
|
const recordsInfoRes = await getRecordsInfoByTime(time, book_id);
|
|
|
- console.log(121, recordsInfoRes);
|
|
|
|
|
|
res.json({
|
|
|
code: 200,
|
|
@@ -138,9 +139,7 @@ router.get("/:book_id/:time", async function (req, res) {
|
|
|
router.get("/:book_id/m/:time", async function (req, res) {
|
|
|
const time = req.params.time; // 获取 fileId 参数
|
|
|
const book_id = req.params.book_id; // 获取 fileId 参数
|
|
|
- console.log(120, time, book_id);
|
|
|
const recordsInfoRes = await getRecordsInfoByMonth(time, book_id);
|
|
|
- console.log(121, recordsInfoRes);
|
|
|
|
|
|
res.json({
|
|
|
code: 200,
|