0

I am using vault services to keep my secrets secure. For that, I need to run the vault script (node fetch-vault-secrets.js) before the next build and next dev command. enter image description here That vault command runs a file that contains a VAULT_SECRET_ID and ROLE_ID. enter image description here I am accessing these secrets through the .env file but these secrets are not fetched before starting the server. How I can solve the problem?

danronmoon
  • 3,814
  • 5
  • 34
  • 56

1 Answers1

0

The doc on fs.writeFile is Asynchronously writes data to a file.

If you want the process to wait for the file to be written (ie, perform the work synchronously), try fs.writeFileSync.

windowsill
  • 3,599
  • 1
  • 9
  • 14
  • The problem is it is not fetching the secrets from the .env file that I used to log in to the vault account. – Usama Tahir Aug 19 '21 at 12:21
  • fs.writeFile is working fine. The problem is I need to read the secret file from the vault and then write it. For reading the secret file I need vault credentials that I stored in the .env file that are not fetched. Hope you understand – Usama Tahir Aug 19 '21 at 14:37
  • No. You will have to show the code your using (not in a screenshot), the error you are getting, and what you expect to happen. – windowsill Aug 19 '21 at 20:50