Denoder / nuxt-module-alternatives

Alternative modules to use while waiting for Nuxt 3 Compatibility
MIT License
144 stars 14 forks source link

"Cannot start nuxt: Cannot read properties of undefined (reading 'http') .. @nuxtjs-alt/http/dist/module.mjs" after upgrading to rc-14 #121

Closed ahoiroman closed 2 years ago

ahoiroman commented 2 years ago

Environment

- Operating System: `Darwin`
- Node Version:     `v18.11.0`
- Nuxt Version:     `3.0.0-rc.14`
- Nitro Version:    `1.0.0`
- Package Manager:  `npm@8.19.2`
- Builder:          `vite`
- User Config:      `build`, `modules`, `publicRuntimeConfig`, `privateRuntimeConfig`, `globalName`, `app`, `i18n`, `http`, `proxy`, `auth`, `tailwindcss`, `googleFonts`
- Runtime Modules:  `@nuxtjs-alt/auth@2.0.16`, `@nuxtjs-alt/http@1.4.5`, `@nuxtjs-alt/proxy@1.3.8`, `@nuxt/content@2.2.2`, `@nuxtjs/tailwindcss@6.1.3`, `@nuxtjs/google-fonts@3.0.0-1`, `@pinia/nuxt@0.4.3`, `@nuxtjs/i18n@8.0.0-beta.3`, `@nuxt/image-edge@1.0.0-27769790.4b27db3`
- Build Modules:    `-`

Nuxt Config

export default defineNuxtConfig({
    build: {
        transpile: ['@heroicons/vue', /echarts/, 'resize-detector', '@headlessui/vue', 'vue-toastification'],
    },
    modules: [
        '@nuxtjs-alt/auth',
        '@nuxtjs-alt/http',
        '@nuxtjs-alt/proxy',
        '@nuxt/content',
        '@nuxtjs/tailwindcss',
        '@nuxtjs/google-fonts',
        '@pinia/nuxt',
        '@nuxtjs/i18n',
        '@nuxt/image-edge',
    ],
    globalName: 'application',
    http: {
        credentials: 'include',
        baseURL: process.env.NUXT_PUBLIC_BASE_URL,
    },
    proxy: {
        '/backend': {
            target: process.env.NUXT_PUBLIC_APP_URL,
            changeOrigin: true,
            secure: process.env.NODE_ENV && process.env.NODE_ENV === 'development' || true,
            rewrite: (path) => path.replace(/^\/backend/, ''),
            // @ts-ignore
            common: {
                'Accept': 'application/json, text/plain, */*'
            },
        },
    },
    auth: {
        globalMiddleware: true,
        redirect: {
            home: '/dashboard',
            logout: '/',
            login: '/auth/signin',
            callback: '/backend/login',
        },
        strategies: {
            // @ts-ignore
            api: {
                provider: 'laravel/sanctum',
                url: process.env.NUXT_PUBLIC_APP_URL,
                cookie: {
                    server: true,
                    name: 'XSRF-TOKEN',
                },
                endpoints: {
                    csrf: {
                        url: '/backend/sanctum/csrf-cookie'
                    },
                    login: {
                        url: '/backend/login'
                    },
                    logout: {
                        url: '/backend/logout'
                    },
                    user: {
                        url: '/backend/api/auth/me'
                    }
                },
                user: {
                    property: {
                        client: false,
                        server: false
                    },
                    autoFetch: true
                }
            },
        }
    },
});

Reproduction

Upgrade from rc13 to rc14 and run npm run dev

Describe the bug

After upgrading to nuxt3-rc14 the following error appears:

Cannot start nuxt:  Cannot read properties of undefined (reading 'http')

  at setup (node_modules/@nuxtjs-alt/http/dist/module.mjs:20:66)
  at normalizedModule (node_modules/@nuxt/kit/dist/index.mjs:167:29)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:416:3)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:1827:7)
  at async load (node_modules/nuxi/dist/chunks/dev.mjs:6779:9)
  at async Object.invoke (node_modules/nuxi/dist/chunks/dev.mjs:6840:5)
  at async _main (node_modules/nuxi/dist/cli.mjs:50:20)

Additional context

No response

Logs

No response

Denoder commented 2 years ago

@ahoiroman update the auth module and http module

ahoiroman commented 2 years ago

@Maxp777 : Is this really something to be discussed in this issue?

The update worked, thanks!