-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't Read Environment Variables in newrelic.js file for @newrelic/next agent #19
Comments
You need to "force" nextjs to read the env variables from your file (i.e. use 'strict'
import { loadEnvConfig } from '@next/env'
loadEnvConfig(process.cwd())
/**
* New Relic agent configuration.
*
* See lib/config/default.js in the agent distribution for a more complete
* description of configuration variables and their potential values.
*/
exports.config = {
/**
* Array of application names.
*/
app_name: ["GSF App 2 NextJS Web App"],
/**
/**
* Your New Relic license key.
*/
license_key: process.env.NEW_RELIC_LICENSE_KEY,
// ...
} |
When I try use: 'use strict'
import { loadEnvConfig } from '@next/env'
loadEnvConfig(process.cwd())
exports.config = {
app_name: process.env.NEW_RELIC_APP_NAME,
license_key: process.env.NEW_RELIC_LICENSE_KEY,
distributed_tracing: {
enabled: true,
},
... returns this error message:
My NEW_RELIC_APP_NAME='my-next-application'
NEW_RELIC_LICENSE_KEY='my_key' |
If your setup is like mine and you use
|
When using
to your and REMOVE
from your This will force the New Relic node agent to read those variables from That's it, no need to "force" reading env vars. Hope this helps |
@matewilk is this method still valid? I'm not seeing the node agent reading .env without adding |
Description
I'm trying to pull in my license_key into the
newrelic.js
file, but it won't read any of my environment variables. I get an error stating that:New Relic for Node.js halted startup due to an error:
Error: Not starting without license key!
my environment variables are stored in a file called
.env.local
Here's an example of my
newrelic.js
file:What I've tried to do
process.env.NEW_RELIC_LICENSE_KEY
require("dotenv").config();
, this then breaks the appnewrelic.js
file. But obviously, for security reasons, I don't want to do this.System Information
The text was updated successfully, but these errors were encountered: