From 00479a060910638895578e2fec5fe7c41dae051a Mon Sep 17 00:00:00 2001 From: moepoi Date: Mon, 15 Nov 2021 17:22:22 +0700 Subject: [PATCH 1/2] Update .gitignore --- .gitignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 95328a6..70cf9ed 100644 --- a/.gitignore +++ b/.gitignore @@ -4,9 +4,6 @@ node_modules/ # Package Manager package-lock.json -# Config -config.js - # IDE Configuration .vscode/ *.code-workspace @@ -38,3 +35,6 @@ Icon Network Trash Folder Temporary Items .apdisk + +# Config +config.js \ No newline at end of file From d142e2bc8496116d06bc81973db2173cf8282207 Mon Sep 17 00:00:00 2001 From: moepoi Date: Mon, 15 Nov 2021 17:25:07 +0700 Subject: [PATCH 2/2] Fix index.js --- index.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/index.js b/index.js index 1ede0ef..bf64d4e 100644 --- a/index.js +++ b/index.js @@ -2,8 +2,15 @@ var express = require("express"); var cookieParser = require("cookie-parser"); var logger = require("morgan"); var bodyParser = require("body-parser"); + const app = express(); +const indexRouter = require('./routes/index'); +const api = require('./routes/api'); + +app.use(express.static("public")); +app.set("view engine", "ejs"); + app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); app.use(logger("dev")); @@ -11,24 +18,19 @@ app.use(express.json()); app.use(express.urlencoded({ extended: false })); app.use(cookieParser()); -const indexRouter = require('./routes/index'); -const api = require('./routes/api'); - app.use('/', indexRouter); app.use('/api', api); -app.use("/", indexRouter); - app.use(function (req, res, next) { - res.header("Access-Control-Allow-Origin", "*"); - res.header( - "Access-Control-Allow-Headers", - "Origin, X-Requested-With, Content-Type, Accept" - ); - next(); + res.header("Access-Control-Allow-Origin", "*"); + res.header( + "Access-Control-Allow-Headers", + "Origin, X-Requested-With, Content-Type, Accept" + ); + next(); }); app.listen("3000", () => { - console.log("Server is running on port : 3000"); + console.log("Server is running on port : 3000"); }); module.exports = app; \ No newline at end of file