Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Local builds fail because Airtable API key is missing #149

Open
Wituareard opened this issue Apr 11, 2024 · 11 comments · Fixed by #150
Open

Local builds fail because Airtable API key is missing #149

Wituareard opened this issue Apr 11, 2024 · 11 comments · Fixed by #150
Labels
bug Something isn't working

Comments

@Wituareard
Copy link
Collaborator

Wituareard commented Apr 11, 2024

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

@Wituareard Wituareard added the bug Something isn't working label Apr 11, 2024
@joepio
Copy link
Collaborator

joepio commented Apr 11, 2024

Maybe a try catch error handler? Not sure.

@Wituareard
Copy link
Collaborator Author

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 Airtable download URLs expires (people of pause) #145

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

@Wituareard
Copy link
Collaborator Author

Included the full solution in the PR

joepio pushed a commit that referenced this issue Apr 15, 2024
…ing (#150)

* Publish .env file with empty value #149

* Exclude /people from prerendering

* Add LinkedIn network to action

* Revert "Add LinkedIn network to action"

This reverts commit 469aaa5.
@joepio
Copy link
Collaborator

joepio commented Apr 23, 2024

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.

@joepio joepio reopened this Apr 23, 2024
@Wituareard
Copy link
Collaborator Author

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
Copy link
Collaborator

joepio commented Apr 23, 2024

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

joepio added a commit that referenced this issue Apr 23, 2024
@joepio
Copy link
Collaborator

joepio commented Apr 23, 2024

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

@Wituareard
Copy link
Collaborator Author

Wituareard commented Apr 23, 2024

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
Copy link
Collaborator Author

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
Copy link
Collaborator Author

Wituareard commented Apr 23, 2024

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
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants