Help

Re: Cloudflare Worker to Proxy Airtable API

3741 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Karl_Hughes
5 - Automation Enthusiast
5 - Automation Enthusiast

I’ve been working on a way to proxy Airtable API calls through a Cloudflare worker. What this library lets you do is add permissions and securely attach your API key to Airtable API requests without letting users see your credentials on the frontend.

Cloudflare Workers are $5/mo, and they run on Cloudflare’s edge network, so they’re really fast for clients. So this project is basically a serverless API proxy, and I’ve found it really useful for making the Airtable API client-side friendly.

Happy to answer questions about implementation or suggestions for improvements!

13 Replies 13
Greg_Stratford
4 - Data Explorer
4 - Data Explorer

This project sounds pretty fantastic. At the moment, my main need for a proxy is for caching and to avoid rate limit issues. Does this project address caching in any way?

Thanks,
Greg

Unfortunately the first version does not add any form of caching. I have created an issue to add it now that Cloudflare Workers have access to cache storage.

Karl,
Thanks for the reply. I’ll keep an eye out our giving adding some caching feature my self a try.

Thanks,
Greg

Evos_World
6 - Interface Innovator
6 - Interface Innovator

Karl, do you have an idiot’s guide to get started. I know nothing about APIs or cloudflare at the moment and keen to use my own html forms with airtable without showing my key.

Thanks

Unfortunately, you have to have a little bit of programming experience to use this library.

One simple solution that doesn’t involve code would be to use a form (like Wufoo or Google forms) hooked up to Zapier. Then, Zapier can be set up to save your data to Airtable.

Evos_World
6 - Interface Innovator
6 - Interface Innovator

Hi Karl

I’d rather not use zapier.

I went on the GitHub page and seemed to have done everything right but when it comes to a uploading to cloudflare (not got an account yet) I get an error?

What’s the error you see when you upload the code to Cloudflare?

Evos_World
6 - Interface Innovator
6 - Interface Innovator

Hi Karl

So basically I have (Detailed explanation I know)
• Created a folder in my local drive called ‘Airtable’
• Downloaded the repo from github and added to the ‘Airtable’ folder
• I’ve then opened Terminal, cd’s into that folder and ran ‘npm install’
• Added my base ID and API key to ‘webpack.config.js’ to the following lines

airtableBaseId: JSON.stringify(process.env.AIRTABLE_API_BASE_ID || ‘appABC12345678’),

and

airtableApiKey: JSON.stringify(process.env.AIRTABLE_API_KEY || ‘keyABC12345678’),

• Then ran ‘npm run build’ in Terminal
• Opened Dist/worker.js in Sublime and copied the contents
• Finally went to https://cloudflareworkers.com and pasted my the contents in the left sidebar and clicked Update.

I then get the error: {“error”:“NOT_FOUND”}

Have I missed something or and I not using the cloudflare part correctly?

I’m ok with doing the html/css side of things but not so great with javascript/php side, I learn some and then forget more lol.

Thanks

Karl_Hughes
5 - Automation Enthusiast
5 - Automation Enthusiast

What url are you going to to see the error?

I think you have to go to a route with the name of the table in it to get results.

Evos_World
6 - Interface Innovator
6 - Interface Innovator

I left the URL as per the original i.e.

airtableApiUrl: JSON.stringify(process.env.AIRTABLE_API_URL || ‘https://api.airtable.com’),

I went to my base > help > api documentation and got my url from the curl example i.e.

https://api.airtable.com/v0/appRIT0loMH2TYFKt/Furniture?api_key=keyABCDE123456

I still get an error though?

Thanks

Nora_Brown
6 - Interface Innovator
6 - Interface Innovator

If you use this proxy, what do the urls to access the API end up looking like? (I’m not familiar with Cloudflare).

I updated the docs this morning to hopefully make it more clear.

Once you upload your script to Cloudflare’s test area, 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 https://tutorial.cloudflareworkers.com/posts.

If you still see a Not Found error, it means your API key or Base ID are not correct.

@Nora_Brown this should answer your question too :grinning_face_with_smiling_eyes: