configuration variable "jwtSecret" for the users-permissions plugin

error: Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with crypto.randomBytes(16).toString('base64')). For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables. Error: Missing jwtSecret. Please, set configuration variable "jwtSecret" for the users-permissions plugin in config/plugins.js (ex: you can generate one using Node with crypto.randomBytes(16).toString('base64')). For security reasons, prefer storing the secret in an environment variable and read it in config/plugins.js. See https://docs.strapi.io/developer-docs/latest/setup-deployment-guides/configurations/optional/environment.html#configuration-using-environment-variables
14 Replies
Percy
Percy2y ago
Project ID: 02d8fb3f-0098-411d-8e69-c595fe28b40f
noahbrandeniers
noahbrandeniersOP2y ago
02d8fb3f-0098-411d-8e69-c595fe28b40f
Brody
Brody2y ago
that is not quite what the error message was telling you to do
Brody
Brody2y ago
you need to run that bit of code like so
Brody
Brody2y ago
then store that resulting value in an environment variable JWT_SECRET then use env('JWT_SECRET') in that config file
noahbrandeniers
noahbrandeniersOP2y ago
Okay thanks, I'm going to give it a try @Brody these are the sets that i took The error message you provided indicates that the Strapi server failed to start properly due to a missing jwtSecret configuration for the users-permissions plugin. This error occurs when the JSON Web Token (JWT) secret is not set, which is required for user authentication and authorization. To resolve this issue, you can follow these steps: 1. Generate a JWT secret: You can generate a JWT secret using Node.js by running the following command in your terminal:
node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"

node -e "console.log(require('crypto').randomBytes(16).toString('base64'))"

2. Set the JWT secret in the environment: For security reasons, it's recommended to store the JWT secret in an environment variable rather than hardcoding it in your code. Set an environment variable named JWT_SECRET and assign it the value of the generated JWT secret. You can do this by adding the following line to your .env file or through your hosting provider's environment variable settings:
JWT_SECRET=your_generated_jwt_secret

JWT_SECRET=your_generated_jwt_secret

3. Configure the jwtSecret in Strapi: Open the config/plugins.js file in your Strapi project and locate the configuration for the users-permissions plugin. Set the jwtSecret property to process.env.JWT_SECRET to read the value from the environment variable. Here's an example of how the configuration should look:
module.exports = ({ env }) => ({
// Other plugin configurations
"users-permissions": {
jwtSecret: env("JWT_SECRET"),
// Other users-permissions configurations
},
});

module.exports = ({ env }) => ({
// Other plugin configurations
"users-permissions": {
jwtSecret: env("JWT_SECRET"),
// Other users-permissions configurations
},
});

4. Restart your Strapi project: After setting the jwtSecret configuration, restart your Strapi project to apply the changes. You can stop the currently running Strapi server and start it again using the following command:
npm run develop

npm run develop

it still doesn't work ...
Brody
Brody2y ago
does it work locally?
noahbrandeniers
noahbrandeniersOP2y ago
Yes it did
Brody
Brody2y ago
show me your railway service variables?
noahbrandeniers
noahbrandeniersOP2y ago
I haven't push it yet, but thanks for aksing. I will keep you updated
Brody
Brody2y ago
dont see how that pertains to my question, but okay lol
noahbrandeniers
noahbrandeniersOP2y ago
sorry i just understood what you mean, i didn't read your message carefully lol @Brody thanks again for your help and it works I was missing to add variables in Railways. Now my next step is to dump my progres database. @Brody Do you know how to do it?
Brody
Brody2y ago
please chill with the pings you want a command line program called pg_dump
noahbrandeniers
noahbrandeniersOP2y ago
Sorry about that, Brody
Want results from more Discord servers?
Add your server