diff options
| author | Jan Tuomi <jan.tuomi@eficode.com> | 2020-01-31 19:20:13 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan.tuomi@eficode.com> | 2020-01-31 19:20:13 +0200 |
| commit | fbf108595a00a7c9db5984158e4b02cc345b68d1 (patch) | |
| tree | f3342eac03006d40a23a49fac94db7061abf5d3c /backend/index.js | |
Initial commit
Diffstat (limited to 'backend/index.js')
| -rw-r--r-- | backend/index.js | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/backend/index.js b/backend/index.js new file mode 100644 index 0000000..a4e27bf --- /dev/null +++ b/backend/index.js @@ -0,0 +1,21 @@ +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); + +const port = 4000; +app.listen(port, () => console.log(`App listening on http://localhost:${port}!`)); |
