-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
33 lines (24 loc) · 1.08 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var express = require('express');
var mongoose = require('mongoose');
var bodyParser = require('body-parser');
var app = express();
// set our port
var port = process.env.PORT || 4500;
mongoose.connect('mongodb+srv://daniel:[email protected]/emberData?retryWrites=true');
app.use(function(req, res, next) {
// Comment the next line for running a local version
res.setHeader('Access-Control-Allow-Origin', 'https://web-miniproject-client.herokuapp.com');
// Uncomment the next line for running a local version
//res.setHeader('Access-Control-Allow-Origin', '*');
res.header("default-src", 'none');
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
res.header('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, OPTIONS');
next();
});
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json()); // to support JSON-encoded bodies
var router = express.Router();
app.use('/', router);
require('./app/routes')(router);
app.listen(port);
exports = module.exports = app;