Skip to content

Instantly share code, notes, and snippets.

@benoror
Last active April 19, 2020 10:51
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save benoror/6ff75023ddfe94edcc5a3ec8a828d8af to your computer and use it in GitHub Desktop.
Save benoror/6ff75023ddfe94edcc5a3ec8a828d8af to your computer and use it in GitHub Desktop.
Node.js Airtable API Proxy
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;
@trickydisco78
Copy link

Looks really good. Do you know how you can secure the API so it won't allow PUT,POST,PATCH and DELETE methods?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment