-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
@bg-dev/nuxt-directus not working with Nuxt 3.12.2 #27589
Description
Environment
Nuxt project info: 15:55:48
- Operating System: Linux
- Node Version: v20.5.1
- Nuxt Version: 3.12.1
- CLI Version: 3.12.0
- Nitro Version: 2.9.6
- Package Manager: pnpm@9.1.1
- Builder: -
- User Config: -
- Runtime Modules: -
- Build Modules: -
Reproduction
Install a base Nuxt App.
Add @bg-dev/nuxt-directus: "^2.4.3" to package.json
Add
{
modules: ['@bg-dev/nuxt-directus'],
directus: {
graphql: {
enabled: false
}
}
}
App is working with nuxt 3.11.2 but not with 3.12.0 or 3.12.1
Describe the bug
When upgrading Nuxt from 3.11.2 to 3.12.1, we get the following error for @bg-dev/nuxt-directus:
Cannot read properties of undefined (reading 'rest')
For other modules, we get similar errors (e.g. Nuxt Content or Nuxt Seo).
Additional context
@bg-dev/nuxt-directus will do the following in module.ts, setup function:
nuxt.options.runtimeConfig = defu(
nuxt.options.runtimeConfig,
{
app: {},
public: {
apollo: {},
directus: options,
},
},
)
But then in the runtime plugin rest.ts, it starts with
export default defineNuxtPlugin((nuxtApp) => {
const config = nuxtApp.$config.public.directus as PublicConfig & { auth: { enabled: true } }
But nuxtApp.$config gives:
{ app: { baseURL: '/', buildId: 'dev', buildAssetsDir: '/_nuxt/', cdnURL: '' },
nitro:
{ envPrefix: 'NUXT_',
routeRules:
{ '/__nuxt_error': [Object],
'/_nuxt/builds/meta/**': [Object],
'/_nuxt/builds/**': [Object] } },
public: {} }
so public is an empty object
In Nuxt 3.11.2 public is public: { apollo: {}, directus: { rest: [Object], graphql: [Object], auth: [Object] } }
Logs
No response