Support Forums

The error of deploying the product developed with nuxtjs to Netlify is not resolved

An error occurred when deploying a development using Laravel on the back end and Nuxtjs on the front end. I was able to develop without problems when developing in the local environment, but an error occurred during deployment.

netlify deploy log

6:23:49 PM:   1. Build command from Netlify app                             
6:23:49 PM: ────────────────────────────────────────────────────────────────
6:23:49 PM: ​
6:23:49 PM: $ npm run generate
6:23:49 PM: > xxx_frontend@1.0.0 generate /opt/build/repo
6:23:49 PM: > nuxt generate
6:23:50 PM: [warn] When using `nuxt generate`, you should set `target: 'static'` in your `nuxt.config`
6:23:50 PM:        👉 Learn more about it on https://go.nuxtjs.dev/static-target
6:24:03 PM: [error] [BABEL] Note: The code generator has deoptimised the styling of /opt/build/repo/node_modules/bootstrap-vue/src/icons/icons.js as it exceeds the max of 500KB.
6:24:24 PM: [error]  /loginBtn
6:24:24 PM: 
6:24:24 PM: TypeError: Cannot read property 'headers' of undefined
6:24:24 PM:     at Store.nuxtServerInit (store/index.js:53:0)
6:24:24 PM:     at Array.wrappedActionHandler (/opt/build/repo/node_modules/vuex/dist/vuex.common.js:853:23)
6:24:24 PM:     at Store.dispatch (/opt/build/repo/node_modules/vuex/dist/vuex.common.js:518:15)
6:24:24 PM:     at Store.boundDispatch [as dispatch] (/opt/build/repo/node_modules/vuex/dist/vuex.common.js:408:21)
6:24:24 PM:     at module.exports.__webpack_exports__.default (.nuxt/server.js:131:0)
6:24:24 PM:     at runNextTicks (internal/process/task_queues.js:62:5)
6:24:24 PM:     at listOnTimeout (internal/timers.js:518:9)
6:24:24 PM:     at processTimers (internal/timers.js:492:7)

nuxt code The source code below is the code to get the user information every time the page is loaded.

  1. Get the token of the cookie and request it as headers information.
  2. Save the value returned from the backend as user information.
export const actions = {
  async nuxtServerInit({ commit },{ req }){
      const token = 'Bearer ' + cookieparser.parse(req.headers.cookie).token
      let user = ''; 
      try {
          user = await this.$axios.$get('/user',{ 
              'Authorization': token,
        } catch (err) {
      commit('setToken',{ token:cookieparser.parse(req.headers.cookie).token});

Hi @tadashimasuda

As per the post Deploy a project with laravel and Vuejs Laravel is not supported on Netlify.
Have you read [Support Guide] Can I run a web server, HTTP listener, and/or database at Netlify?

Laravel does not use netlify. Sorry for the confusing text.

I’m still working on my Nuxt.js skills.

Perhaps this might help Cannot read property 'headers' of undefined after Nuxt Generate · Issue #53 · nuxt-community/i18n-module · GitHub

1 Like

Hi, @tadashimasuda :wave:

Welcome to the Netlify Forums! Looks like this thread has been a bit quiet the past few days. Did the github issue @coelmay linked help you here? Let us know. :slight_smile: