Airtable Proxy Cloudflare Worker
- Keep your Airtable Base ID and API Key secret while still allowing frontend apps to access data from Airtable's API.
- Limit requests to specific methods and tables. For example, using this library, you can make sure that public users can only make
GETrequests to your tables.
- Automatically build and push updates to your Cloudflare Worker using Travis-CI.
- Cloudflare account with Workers enabled.
- An Airtable Base ID and your Airtable API key.
- Node and Node Package Manager (npm).
- Familiarity with your computer's terminal/command line interface.
The easiest way to see this project in action is to build your Worker locally and copy/paste it into Cloudflare's UI:
- Clone this repo:
git clone https://github.com/portable-cto/airtable-proxy-worker.git
- Install dependencies:
- Build the worker with your Airtable App/Base ID and API Key:
AIRTABLE_API_BASE_ID=appXXXXXXXXX AIRTABLE_API_KEY=keyXXXXXXXXXX npm run build
- Upload the built
dist/worker.jsfile to cloudflareworkers.com to test your script.
Your Airtable's tables will be available via the table name. For example, if my Airtable base has a table name
posts, it would be available at
In order to deploy the worker to your own personal worker, upload it via the web UI and click "Deploy".
By default, the routes for each of your tables are available at
YOUR_CLOUDFLARE_DOMAIN/RESOURCE_NAME. For example, if my custom domain is
http://api.example.com and the table I want to access is called
users, I would access the API at
You can change this routing using a
PROXY_PREFIX as described in the Configuration section below.
You can also use Travis to automatically deploy updates to your Worker. Just add the following environment variables to your Travis settings:
deploy block in the
.travis.yml file will automatically update your worker in Cloudflare when the
master branch is built using the script at
In addition to the required
AIRTABLE_API_BASE_ID variables, you can also set the following configuration options as ENV vars:
AIRTABLE_API_URL- Defaults to
AIRTABLE_API_VERSION- Defaults to
PROXY_PREFIX- Use this if your Cloudflare worker's routes are prefixed by something before the Airtable resource name. For example, you may want to call
mycustomdomain.com/posts. In this example, you would add
apias a prefix.
ALLOWED_TARGETS- Use this to lock down your Airtable API to specific resources and methods. For example, a stringified JSON object like this:
PUTrequests on the
postsresource and all request methods on the
commentsresource. Allows all methods for all resources by default.
PROXY_CACHE_TIME- Defaults to
0. The number of seconds set on the
Cache-Controlheader to use Cloudflare's caching.
Contributions are welcome and encouraged! When contributing to this repository, please first discuss the change you wish to make via the issues on Github.
Before you make a pull request, please add or update any relevant tests. You can run the test suite (uses Jest):
npm run test:local
Also run Prettier to ensure that code styling is consistent:
npm run prettier.
Pull Request Process
- Make sure tests are running and linting passes before you submit a PR.
- Update any relevant parts of the documentation in the
- Update the
changelog.mdfile with any new updates, breaking changes, or important notes.
- Run the build process to make sure it passes too:
npm run build.
- Include a link to any relevant issues in the PR on Github. If there are problems with your PR, we will discuss them in Github before merging.
This library uses semantic versioning to inform users of breaking and non-breaking changes. When a new release is ready, the following steps will be taken:
- Make sure tests still pass:
- Run the release script:
npm version <SEMANTIC_VERSION> && git push --tagswith the release number you want to use.
This will create a new Tag in Github.
The MIT License (MIT)
Copyright (c) 2018 Portable CTO, LLC
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.