PauseAI / pauseai-website

Website for PauseAI.info
https://pauseai.info
Other
10 stars 29 forks source link

Local builds fail because Airtable API key is missing #149

Open Wituareard opened 2 months ago

Wituareard commented 2 months ago

Local builds fail because the environment variable containing the Airtable API key is missing. Not sure about the best way to fix this.

joepio commented 2 months ago

Maybe a try catch error handler? Not sure.

Wituareard commented 2 months ago

It's a two-part problem:

  1. The compilation fails because the environment variable is missing
  2. If the environment variable is present but invalid, fetching the results fails

I'd suggest

  1. moving the API keys for local testing to a .env.local file and publishing a .env file with empty values to Git as suggested in the Vite guide
  2. excluding /people from prerendering, which would also resolve #145

I'll create a PR for 1. so you can rename your local file before removing the name from the .gitignore

Wituareard commented 2 months ago

Included the full solution in the PR

joepio commented 2 months ago

I think publishing a .env is a bad practice, very easy to leak secrets this way.

We should circumvent the initial setup bug in some other way, and re-add the .env to .gitignore.

Wituareard commented 2 months ago

I was a bit skeptical as well but chose to propose it anyway because it's suggested in the Vite guide. The previous version excluded a .env.example which could be a solution, but I don't know if that would overwrite the .env.local.

joepio commented 2 months ago

I could add a template.env and a line to the readme. The .env will be added to the gitignore to prevent leaks

joepio commented 2 months ago

What do you think of this @Wituareard ? OK to close?

Wituareard commented 2 months ago

It tested it and .env.example is overwritten by both .env and .env.local so I'd prefer that solution because it works plug-and-play. Additionally, I could add a big warning to .env.example.

Wituareard commented 2 months ago

Okay nvm .env.example isn't loaded at all. Maybe a big warning in .env would be enough?

#  _____                 _                  _                                            _          _                       _ 
# |  __ \               | |                | |                                          | |        | |                     | |
# | |  | |  ___   _ __  | |_    ___  _ __  | |_  ___  _ __   ___   ___   ___  _ __  ___ | |_  ___  | |__    ___  _ __  ___ | |
# | |  | | / _ \ | '_ \ | __|  / _ \| '_ \ | __|/ _ \| '__| / __| / _ \ / __|| '__|/ _ \| __|/ __| | '_ \  / _ \| '__|/ _ \| |
# | |__| || (_) || | | || |_  |  __/| | | || |_|  __/| |    \__ \|  __/| (__ | |  |  __/| |_ \__ \ | | | ||  __/| |  |  __/|_|
# |_____/  \___/ |_| |_| \__|  \___||_| |_| \__|\___||_|    |___/ \___| \___||_|   \___| \__||___/ |_| |_| \___||_|   \___|(_)
#
# Secrets go in a .env.local file.
Wituareard commented 2 months ago

But I can also live with the current solution. I'd just prefer if it worked out-of-the-box.

If you want to keep the current solution, you can close the issue.

moiri-gamboni commented 2 months ago

Hi, I'm working on bringing a version of the website online for France and I ran into this. The /teams route is also currently prerendered, so even with /people excluded the build fails if the API key is present but invalid (which is the case after following the setup instructions). Excluding /teams from prerendering works for building but idk if that's something you want to do, given that if I understand correctly there's no attachments on that page. If I might suggest something, it's possible to build in "development" mode though, so you can disable prerendering only in that case. On a related note, I also think the Airtable URLs should be in the environment, even if they're not secret. I personally also added checks to see if all these variables are set. I'm happy to submit PRs for any of this.