Configuration
Module nuxt-beditacan be customized throught the bedita property of nuxt.config.
export default defineNuxtConfig({
modules: [
'@atlasconsulting/nuxt-bedita',
],
bedita: {
apiBaseUrl: 'http://bedita-api.localhost',
apiKey: '1a2bc3d4',
session: {
name: 'nuxt-bedita',
secret: '<at-least-32-chars-secret-string>',
},
},
})
NUXT_ to configure some module properties by environment instead of edit the bedita property.apiBaseUrl required
The BEdita API base URL.
| Type | Default | Options | Env |
|---|---|---|---|
string | - | - | NUXT_BEDITA_API_BASE_URL |
apiKey required
The BEdita API key.
| Type | Default | Options | Env |
|---|---|---|---|
string | - | - | NUXT_BEDITA_API_KEY |
auth
Configure user auth stuff as the auth middleware that is responsible for fill the user state reading from session and to protect routes too.
| Type | Default | Options | Env |
|---|---|---|---|
Object |
auth: {
global: true,
required: false,
publicRoutes: [],
unauthenticatedRedirect: '/sign-in',
rolesGuard: {},
sessionUserProps: [],
},
|
|
- |
endpoints
List of internal API endpoints' groups enabled.
Two endpoints' groups are available:
authenable all endpoints related to user autenticationPOST /api/bedita/authuser authenitcation/api/bedita/auth/logoutuser logoutPOST /api/bedita/auth/resetrequest of password resetPATCH /api/bedita/auth/changechange passwordPOST /api/bedita/auth/optoutuser opt-out
signupenable all endpoints related to signup flowPOST /api/bedita/signupuser signupPOST /api/bedita/signup/activationuser signup activation
| Type | Default | Options | Env |
|---|---|---|---|
Array | ['auth', 'signup'] | auth, signup | - |
projects
Used to setup different API configuration. For example:
export default defineNuxtConfig({
modules: [
'@atlasconsulting/nuxt-bedita',
],
bedita: {
projects: {
one: {
apiBaseUrl: 'http://bedita-api-one.localhost',
apiKey: 's9suff64h',
},
two: {
apiBaseUrl: 'http://bedita-api-two.localhost',
apiKey: 'plog8uhcft',
},
},
},
})
In the app you can call a special endpoint /api/bedita/_project to set the project to use.
await $fetch('/api/bedita/_project', {
method: 'POST',
body: { project: 'two'},
})
Once setup project every call to BEdita API will use the project two configuration.
| Type | Default | Options | Env |
|---|---|---|---|
Object |
projects: Record <string, BeditaProjectConf>
|
- | NUXT_BEDITA_PROJECTS |
proxyEndpoints
Use this property to enable/disable API proxy to BEdita API. It is configurable per endpoint.
By default all GET requests at /api/bedita except /api/bedita/users and /api/bedita/profiles are proxied to BEdita API (if not found in routing context), for example a request in the app to /api/bedita/documents will be proxied to GET /documents BEdita API.
It is possible to limit the requests proxied defining the endpoints allowed.
For example the following configuration enable GET /api/bedita/events and GET /api/bedita/news while other GET /api/bedita/<other-bedita-endpoint> request will return a 404 Not Found.
export default defineNuxtConfig({
modules: [
'@atlasconsulting/nuxt-bedita',
],
bedita: {
proxyEndpoints: [
{
path: '/events',
methods: ['GET'],
},
{
path: '/news',
methods: ['GET'],
}
],
},
})
Another way is using the option regExp to define a regular expression to test the URL path.
The example below is equivalent to that above:
export default defineNuxtConfig({
modules: [
'@atlasconsulting/nuxt-bedita',
],
bedita: {
proxyEndpoints: [
{
regExp: '^/(events|news).*$',
methods: ['GET'],
},
],
},
})
regExpmust be a string as you would pass to RegExp() constructor.| Type | Default | Options | Env |
|---|---|---|---|
Array |
proxyEndpoints: [
{
regExp: '^/(?!users|profiles).*$', // all endpoints except `users` and `profiles` are allowed
methods: ['GET'], // HTTP methods allowed
},
]
|
- | - |
recaptcha
reCAPTCHA v3 can be enabled to protect login, signup and other actions that require it. By default it is disabled.
| Type | Default | Options | Env |
|---|---|---|---|
Object |
recaptcha: {
enabled: false,
hideBadge: false,
useRecaptchaNet: false,
},
|
|
removeLinksMember
Configure BEdita client to remove links member from API response.
| Type | Default | Options | Env |
|---|---|---|---|
boolean | false | - | - |
replaceTranslations
Configure BEdita client to replace in the API response the main language attributes of BEdita objects with translated fields requested via lang query string.
With this option enabled you can always refer to main objects attributes to get the requested translation.
Example:
GET /api/bedita/documents
will returns documents with attributes in the main language.
GET /api/bedita/documents?lang=it
will returns documents with attributes in the Italian language, if exists.
| Type | Default | Options | Env |
|---|---|---|---|
boolean | false | - | - |
session required
Contain session configuration as the session name and session secret used to encrypt session. The session take advantage of unjs/h3 sessions storing values in a cookie sealed with the session secret.
| Type | Default | Options | Env |
|---|---|---|---|
Object |
session: {
name: 'bedita',
secret: '',
},
|
|
|