-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (27 loc) · 872 Bytes
/
index.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 proxy = require('http-proxy-middleware');
require('dotenv').load();
var options = {
logLevel: 'debug',
target: 'https://cdn.contentful.com/spaces/' + process.env.APP_ID,
changeOrigin: true,
headers: {
'Authorization': 'Bearer ' + process.env.API_KEY
},
pathRewrite: {
'^/api' : ''
},
// http://stackoverflow.com/questions/14262986/node-js-hostname-ip-doesnt-match-certificates-altnames
// https://github.com/nodejitsu/node-http-proxy/blob/f345a1ac2dde1884e72b952a685a0a1796059f14/lib/http-proxy/common.js#L54
secure: false,
ssl: {
rejectUnauthorized: false
}
};
var apiProxy = proxy(options);
var app = express();
app.use('/api/**', apiProxy);
var server = app.listen(process.env.PORT || 3000, function(){
console.log('Listening on port ' + server.address().port);
});
module.exports = app;