From 3aae4fca393e16740f7d029cb88dd0d6d800f347 Mon Sep 17 00:00:00 2001 From: CxJuice <110189934+CxJuice@users.noreply.github.com> Date: Fri, 6 Oct 2023 02:28:50 +0800 Subject: [PATCH] Update server.js --- server.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/server.js b/server.js index f4400ad..47b66b4 100644 --- a/server.js +++ b/server.js @@ -1,14 +1,11 @@ const express = require('express'); const fs = require('fs'); const path = require('path'); -const cors = require('cors'); // <-- 导入 cors 中间件 const app = express(); const PORT = process.env.PORT || 3000; const JSON_FOLDER_PATH = path.join(__dirname, 'json'); -app.use(cors()); // <-- 使用 cors 中间件以允许所有来源 - // 获取文件夹内的所有 JSON 文件 app.get('/json-files', (req, res) => { fs.readdir(JSON_FOLDER_PATH, (err, files) => { @@ -42,4 +39,4 @@ app.get('/json-files/:filename', (req, res) => { app.listen(PORT, () => { console.log(`Server is running on port ${PORT}`); -}); +});