When ever I create a strapi environment with npx create-strapi-app The server.js file in config folder has this admin jwt secret environment variable what is it used for
module.exports = ({ env }) => ({
host: env('HOST', '0.0.0.0'),
port: env.int('PORT', 1337),
admin: {
auth: {
secret: env('ADMIN_JWT_SECRET', 'dfee1c43fb8d2e506ad627'),
},
},
});
CodePudding user response:
server.admin.auth.secret used in JWT token creation during admin authorization process
earlier 3.1 secret for admin part generated automatically, but since 3.1 it should be part of config. Please, check migration guide.
Let's check source code authentication.js
We can see that createJwtToken used for token creation for admin part.
Definition here services/token.js
It refer to
const getTokenOptions = () => {
const { options, secret } = strapi.config.get('server.admin.auth', {});
return {
secret,
options: _.merge(defaultJwtOptions, options),
};
};
and here you can see that secret from server.js used for JWT creation. server.js config propose to use environment variable with ADMIN_ prefix to identify that it's admin part related and separated from JWT for API
