A course tracker app using airtable proxy server and hosted on cloudflare worker
Link to project: https://course-tracker-airtable-cloudflare-severless.pages.dev/
Tech used:
One of the first thing I would optimize and refactor the code to increase efficiency and productivity
Utilized the airtable proxy server using to protect user api keys and base id from client side. Also working cloudflare worker commmand run the severless function
- 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.
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 http://api.example.com/users
.
You can change this routing using a PROXY_PREFIX
as described in the Configuration section below.
In addition to the required AIRTABLE_API_KEY
and AIRTABLE_API_BASE_ID
variables, you can also set the following configuration options as ENV vars:
AIRTABLE_API_URL
- Defaults tohttps://api.airtable.com
.AIRTABLE_API_VERSION
- Defaults tov0
.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 callmycustomdomain.com/api/posts
instead ofmycustomdomain.com/posts
. In this example, you would addapi
as 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:'[{"resource":"posts","method":"GET,PUT"},{"resource":"comments","method":"*"}]'
will allowGET
andPUT
requests on theposts
resource and all request methods on thecomments
resource. Allows all methods for all resources by default.PROXY_CACHE_TIME
- Defaults to0
. The number of seconds set on theCache-Control
header to use Cloudflare's caching.
- Clone repo
- run
npm intall
- cd worker update AIRTABLE_API_KEY
- cd worker update AIRTABLE_API_BASE_ID
- update the fetch URL =
https://airtable-proxy-worker.signalnerves.workers.dev/
- update airtable table name =
courses
The AIRTABLEAPI_KEY and AIRTABLE_API_BASE_ID should be set using wrangler secret
, a subcommand of wrangler
for setting _encrypted environment varibles. Run wrangler secret put
as seen below, and paste in your API key:
$ wrangler secret put AIRTABLE_API_KEY
Enter the secret text you would like assigned to the variable AIRTABLE_API_KEY on the script named airtable-form-handler:
******
🌀 Creating the secret for script name airtable-form-handler
✨ Success! Uploaded secret AIRTABLE_API_KEY.