Environment variables keep disappearing, Chapter 25

Everytime i run vapor xcode -y, the environment variables for github/google get wiped.

Is this normal? How would this be handled in production.

thanks

@jjjeeerrr111 this is normal and an unfortunate side-effect of using SwiftPM with Xcode before Xcode 11.

What I do is use .env files to store my secrets in, these files don’t get checked into Git to keep them secure and the app loads them up every time is starts so you don’t have to constantly enter them. Have a look at this gist from @jonasschwartz on how to use it.

This functionality will probably be baked into Vapor in Vapor 4 and will definitely make its way into the next edition of the book!

@0xtim Thanks for answering!

How would you go about populating your DB with static data? For example I just want to host a bunch of text on the server so that users can fetch it from an api call.

Im not sure how to do that since the tutorial only covers user generated data

You can pre-populate the DB using migrations - there’s a section in the book about that where it creates the admin user. Here’s the relevant code:

Hope that helps!