Skip to content
This repository was archived by the owner on Oct 10, 2026. It is now read-only.
This repository was archived by the owner on Oct 10, 2026. It is now read-only.

globals.Headers is not a constructor #174

Open

Description

@nlaitan

I get this error on a production environment, not in development mode. When I acess to link with a nuxt link in page, error doesn't ocurrs, only ocurrs when I enter on the page with url directly (refreshing for example also ocurrs)

Error stack:

ERROR  globals.Headers is not a constructor
  at mergeHeaders (node_modules_dev/ky/index.js:52:0)
  at deepMerge (node_modules_dev/ky/index.js:88:0)
  at validateAndMerge (node_modules_dev/ky/index.js:509:0)
  at Function.ky.<computed> [as get] (node_modules_dev/ky/index.js:516:0)
  at http_HTTP.module.exports.http_HTTP.<computed> [as get] (.nuxt/http.js:95:0)
  at http_HTTP.module.exports.http_HTTP.<computed> [as $get] (.nuxt/http.js:126:0)
  at asyncData (pages/catalogue.vue:36:0)
  at promisify (.nuxt/utils.js:278:0)
  at server.js:72810:23
  at Array.map (<anonymous>)
2021-04-13T02:52:13.304Z	ERROR	Unhandled Promise Rejection 	{"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"TypeError: globals.Headers is not a constructor","reason":{"errorType":"TypeError","errorMessage":"globals.Headers is not a constructor","stack":["TypeError: globals.Headers is not a constructor","    at mergeHeaders (node_modules_dev/ky/index.js:52:0)","    at deepMerge (node_modules_dev/ky/index.js:88:0)","    at validateAndMerge (node_modules_dev/ky/index.js:509:0)","    at Function.ky.<computed> [as get] (node_modules_dev/ky/index.js:516:0)","    at http_HTTP.module.exports.http_HTTP.<computed> [as get] (.nuxt/http.js:95:0)","    at http_HTTP.module.exports.http_HTTP.<computed> [as $get] (.nuxt/http.js:126:0)","    at asyncData (pages/catalogue.vue:36:0)","    at promisify (.nuxt/utils.js:278:0)","    at server.js:72810:23","    at Array.map (<anonymous>)"]},"promise":{},"stack":["Runtime.UnhandledPromiseRejection: TypeError: globals.Headers is not a constructor","    at process.<anonymous> (/var/runtime/index.js:35:15)","    at process.emit (events.js:327:22)","    at processEmit [as emit] (/var/task/node_modules/signal-exit/index.js:161:32)","    at processPromiseRejections (internal/process/promises.js:245:33)","    at processTicksAndRejections (internal/process/task_queues.js:94:32)"]}
Unknown application error occurred

error is on a page, in this part:

  async asyncData({ $http }) {
    const data = await $http.$get(`xxx`)
    return { data }
  }

nuxt.config.js

...
modules: [
  '@nuxt/http'
]
...
http: {
    baseUrl: process.env.API_URL,
},

Versions:

@nuxt/http: 0.6.4
nuxt: 2.14.12

Activity

  1. oritwoen commented on Apr 17, 2021

    @oritwoen

    I also have this bug on production Vercel.

     ERROR  TypeError: globals.Headers is not a constructor  at server.js:52993:11  at http_HTTP.module.exports.http_HTTP.<computed> [as get] (.nuxt/http.js:113:0)  at http_HTTP.module.exports.http_HTTP.<computed> [as $get] (.nuxt/http.js:126:0)
  2. thezzisu commented on May 3, 2021

    @thezzisu

    +1 for Vercel.

    globals.Headers is not a constructor
    
  3. varna commented on Jun 14, 2021

    @varna

    Still doesn't work.
    Might have something to do with sindresorhus/ky-universal#23
    I tried to confirm that the latest release has https://github.com/nuxt/http/pull/121/files fix. But I can't wrap my head around which branch is 0.6.4

  4. varna commented on Jun 14, 2021

    @varna

    I started receiving this after upgrading nuxt from 2.14.12 to 2.15.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions