W
Wasp-lang•4mo ago
Connor

Custom key file not able to be referenced after compiling

Is there a way to reference a google cloud key.json file after compiling? I currently have it placed in the /app directory and storing that path to the key as an .env var. Is there a way to make sure that file is also moved into the compiled project after running wasp start? Thanks for your help!
6 Replies
kapa.ai
kapa.ai•4mo ago
Hi @Connor. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Hmm, I don't know enough to give you a confident answer yet. However, I can tell you that Wasp currently doesn't have a built-in way to handle static files like your key.json file. There is an open issue on the Wasp GitHub repository discussing the need for documentation on how to import JSON files or read static files in Wasp on the server side. You can follow the discussion here (https://github.com/wasp-lang/wasp/issues/1564). In the meantime, you might want to consider other ways to securely store and access your Google Cloud key, such as using environment variables. Wasp has a detailed guide on how to define environment variables both in development and in production, which you can find here (https://wasp-lang.dev/docs/project/env-vars). Remember, if you are storing sensitive information like API keys, it's recommended to use server environment variables, as they are not publicly readable. Here's how you can read them in your server code:
console.log(process.env.YOUR_VAR_NAME)
console.log(process.env.YOUR_VAR_NAME)
I hope this helps, and I recommend keeping an eye on the Wasp GitHub repository for updates on the issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Connor, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
Filip
Filip•4mo ago
Hey @Connor! You can place it the public dir, but I'm guessing this file is private?
Connor
Connor•4mo ago
Yeah, the file would be private
MEE6
MEE6•4mo ago
Wohooo @Connor, you just became a Waspeteer level 2!
Connor
Connor•4mo ago
Is there any other way to store private files or vars than the .secret.env?
Filip
Filip•4mo ago
Yeah, unfortunately no way for that yet 😅 For now, your best bet is storing that json into an environment variable or making sure you deploy it yourself. Would this work for you. Thanks a lot for your feedback though, I've just created an issue for implementing this: https://github.com/wasp-lang/wasp/issues/2175
Want results from more Discord servers?
Add your server