Skip to content

Commit dfcf04f

Browse files
author
Henri Van den Braembussche
committed
CORS
1 parent 86469dd commit dfcf04f

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,16 @@ var users = require('./routes/users');
1515
var app = express();
1616
app.use(bodyParser.json());
1717
app.use(bodyParser.urlencoded({ extended: true }));
18-
app.get('/members', githubWebhook.getMembers);
1918
env.config();
2019
app.use(cors());
20+
21+
var corsOptions = {
22+
origin: 'https://lab9k.gent',
23+
optionsSuccessStatus: 200 // some legacy browsers (IE11, various SmartTVs) choke on 204
24+
}
25+
26+
app.get('/members',cors(corsOptions), githubWebhook.getMembers);
27+
2128

2229

2330
// view engine setup

src/githubWebhook.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,13 @@ module.exports= {
88
uri: 'https://api.github.com/orgs/lab9k/members',
99
headers: {
1010
'User-agent':'henrivdb',
11-
Authorization: 'token '+process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
11+
Authorization: 'token '+ process.env.GITHUB_PERSONAL_ACCESS_TOKEN,
1212
}
1313
};
1414

1515
request.get(options, function (error, response, body) {
1616
res.status(200).send(body);
1717
console.log('error:', error); // Print the error if one occurred
18-
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
19-
console.log('body:', body); // Print the HTML for the Google homepage.
2018
});
2119

2220
},

0 commit comments

Comments
 (0)