Skip to content

Instantly share code, notes, and snippets.

@lyushenko
Created January 5, 2017 14:34
Show Gist options
  • Save lyushenko/06763dd22a97a154fb76179f0b8cbdce to your computer and use it in GitHub Desktop.
Save lyushenko/06763dd22a97a154fb76179f0b8cbdce to your computer and use it in GitHub Desktop.
Node.js proxy to Airtable API
var express = require('express');
var proxy = require('http-proxy-middleware');
var options = {
logLevel: 'debug',
target: 'https://api.airtable.com/v0/' + process.env.APP_ID,
changeOrigin: true,
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer ' + process.env.API_KEY
},
pathRewrite: {
'^/api' : ''
},
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;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment