Skip to main content

Configuration

Auth7 can be configured using the init() function.


Example​

auth7.init({
mongoURI: "mongodb://localhost:27017/auth7",
jwtSecret: "secret",
accessTokenExpiry: "15m",
refreshTokenExpiry: "7d",
cookieSecure: false,
});

Configuration Options​

OptionDescription
mongoURIMongoDB connection string
jwtSecretSecret used for JWT
accessTokenExpiryAccess token expiry time
refreshTokenExpiryRefresh token expiry
cookieSecureEnable secure cookies

Custom User Fields​

You can extend the user schema.

auth7.init({
userFields: {
username: String,
role: String,
},
});

This allows storing additional user information.