Skip to content

Commit 2ecd209

Browse files
author
Dassi Orleando
committed
Enable CORS
1 parent a24b640 commit 2ecd209

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

index.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1+
/**
2+
* NodeJS entry file to initialize the App
3+
* @author dassiorleando
4+
*/
15
// Get dependencies
2-
const express = require('express');
3-
const path = require('path');
4-
const http = require('http');
5-
const bodyParser = require('body-parser');
6-
// Get gist route
7-
const api = require('./server/routes/api');
8-
const app = express();
6+
var express = require('express'),
7+
path = require('path'),
8+
http = require('http'),
9+
cors = require('cors'),
10+
bodyParser = require('body-parser'),
11+
12+
// Get gist route
13+
api = require('./server/routes/api'),
14+
app = express();
15+
16+
// Enable CORS for all routes
17+
app.use(cors());
18+
919
/**
1020
* Create HTTP server.
1121
*/
12-
const server = http.createServer(app);
22+
var server = http.createServer(app);
1323
// Socket.io for real time communication
1424
var io = require('socket.io').listen(server);
1525

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"angular2-toaster": "^3.0.1",
3232
"body-parser": "^1.17.1",
3333
"core-js": "2.5.3",
34+
"cors": "^2.8.5",
3435
"express": "^4.15.2",
3536
"hammerjs": "^2.0.8",
3637
"http-status": "^1.0.1",

0 commit comments

Comments
 (0)