-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Hi,
Having an issue with webpacker initializer.
As pointed in the env doc I create an initializer to pass Rails application variables to a JS frontend, process.env.FRONTEND_API_KEY
ends up empty.
It has already been talked about but left unsolved.
Am I doing something wrong or missing something ?
# in config/initializersd/webpacker.rb
Webpacker::Compiler.env['FRONTEND_API_KEY'] = Rails.application.credentials.dig(Rails.env.to_sym, :some_api_key)
# Webpacker.compiler.env returns a hash with the data
// in application.js
console.log(process.env.FRONTEND_API_KEY)
// returns undefined
I'm having the same issue as @nozpheratu - setting variables with
Webpacker::Compiler.env
doesn't seem to make it into the actual javascript environment. Anyone have a suggestion? Did this break somewhere?
Originally posted by @bbugh in #691 (comment)
jahammo2 and masarufuruya
Metadata
Metadata
Assignees
Labels
No labels