antfu-collective / vite-ssg

Static site generation for Vue 3 on Vite
MIT License
1.32k stars 136 forks source link

let headers = new Headers() returning undefined in @servicestack node modules #384

Open da-cade opened 10 months ago

da-cade commented 10 months ago

Describe the bug

Attempted to run npm run build:local from ProjectName/ui

An internal error occurred. [vite-ssg] Please report an issue, if none already exists: https://github.com/antfu/vite-ssg/issues ~\ProjectName\ui\node_modules\@servicestack\client\dist\index.js:631
this.headers = new Headers(); ^

ReferenceError: Headers is not defined at new JsonServiceClient (~\ProjectName\ui\node_modules\@servicestack\client\dist\index.js:631:28)

let headers = new Headers(); headers.set("Content-Type", "text/plain");

Since it is a node-module, adjusting locally would be pointless. After some searching, the typical solution for this is to populate the Headers object with a prior await fetch.Headers( )

Reproduction

Follow the steps located at https://vue-ssg.jamstacks.net/, and attempt to build. All other steps run fine.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 9 4900HS with Radeon Graphics
    Memory: 5.59 GB / 15.42 GB
  Binaries:
    Node: 16.15.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.6.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.3636.0), Chromium (119.0.2151.97)
    Internet Explorer: 11.0.19041.3636

Used Package Manager

npm

Validations