Is it possible to store a JSON file to an ENV variable with dotenv?
You could just put the item on one line like:
VITE_FIREBASE={"apiKey":"slslsls","slsls":"lelsls"}
You just have to make sure your keys have quotes in them.
and get them (SvelteKit example) like so:
const p = process?.env ? process.env : import.meta.env;
const firebase_config = JSON.parse(p.VITE_FIREBASE);
J
Convert the JSON object to string and store it in the ENV
You can use JSON.dump
to convert JSON object to string
and then in your controller JSON.parse(ENV['CLIENT_SECRET'])
Alternatively
you can create a google_session.rb
inside initializers
folder
$google_session = GoogleDrive::Session.from_service_account_key(
# config goes here
)
and in your controller you will have access to $google_session
global variable