mirror of
https://gitlab.com/nekoya/web.git
synced 2024-12-23 06:50:30 +01:00
Fix index.js
This commit is contained in:
parent
00479a0609
commit
d142e2bc84
1 changed files with 14 additions and 12 deletions
26
index.js
26
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;
|
Loading…
Reference in a new issue