From a5ae2653d8ccdaf00270c0c8c8a30b88d7955114 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 1 Feb 2020 16:33:56 +0200 Subject: Do stuff --- backend/src/index.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 backend/src/index.js (limited to 'backend/src/index.js') diff --git a/backend/src/index.js b/backend/src/index.js new file mode 100644 index 0000000..128ed60 --- /dev/null +++ b/backend/src/index.js @@ -0,0 +1,22 @@ +const express = require('express'); +const bodyParser = require('body-parser'); +const cookieParser = require('cookie-parser'); +const morgan = require('morgan'); +const routes = require('./routes'); + +const app = express(); + +app.use(morgan('dev')); +app.use(bodyParser.json()); +app.use(cookieParser()); +app.use((req, res, next) => { + res.set('Access-Control-Allow-Origin', 'http://localhost:3000'); + res.set('Access-Control-Allow-Headers', 'Content-Type'); + res.set('Access-Control-Allow-Credentials', true); + next(); +}); +app.use(routes.normalRouter); +app.use(routes.authedRouter); + +const port = 4000; +app.listen(port, () => console.log(`App listening on http://localhost:${port}!`)); -- cgit v1.3