Skip to content

[BUG] Building static sites from api requests produces invalid json #566

@fursund

Description

@fursund

Describe the bug

Building app produces invalid json:

{"kind":"FETCH","data":{"headers":{"accept-ranges":"bytes","alt-svc":"h3=\":443\"; ma=2592000,h3-29=\":443\"; ma=2592000","apicdn-cache-control":"public, max-age=60, s-maxage=3600, stale-while-revalidate=60, stale-if-error=3600","cache-control":"public, max-age=60, s-maxage=60, stale-while-revalidate=15, stale-if-error=3600","content-encoding":"br","content-length":"299","content-type":"application/json; charset=utf-8","date":"Fri, 11 Apr 2025 10:06:32 GMT","sanity-gateway":"k8s-gcp-eu-w1-prod-ing-01","sanity-query-hash":"***","server-timing":"api;dur=25","strict-transport-security":"max-age=63072000; includeSubDomains; preload","vary":"accept-encoding, origin","via":"1.1 google","x-sanity-age":"0","x-sanity-shard":"gcp-eu-w1-prod-40012"},"body":"***","status":200,"url":"https://***.apicdn.sanity.io/v2023-05-03/data/query/production?query=*%5B_type+%3D%3D+%22format%22+%26%26+isImport%5D.shortName"},"revalidate":31536000,"tags":[]}"tags":[]}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

SyntaxError: Unexpected non-whitespace character after JSON at position 1646
    at JSON.parse (<anonymous>)
    at file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/aws/dist/build/createAssets.js:122:35
    at file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/aws/dist/build/helper.js:159:13
    at Array.forEach (<anonymous>)
    at Module.traverseFiles (file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/aws/dist/build/helper.js:151:51)
    at createCacheAssets (file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/aws/dist/build/createAssets.js:120:21)
    at build (file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/cloudflare/dist/cli/build/build.js:56:44)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async file:///Users/fursund/Dev/convert3d/node_modules/@opennextjs/cloudflare/dist/cli/index.js:40:1```

### Steps to reproduce

Use generateStaticParams with an api to produce paths

### Expected behavior

It builds. Works on next-on-pages.

### @opennextjs/cloudflare version

1.0.0-beta.2

### Wrangler version

4.10.0

### next info output

```shell
Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041
  Available memory (MB): 131072
  Available CPU cores: 16
Binaries:
  Node: 20.15.0
  npm: 10.2.3
  Yarn: N/A
  pnpm: 9.4.0
Relevant Packages:
  next: 14.2.28 // An outdated version detected (latest is 15.3.0), upgrade is highly recommended!
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.2.2
Next.js Config:
  output: N/A
 ⚠ An outdated version detected (latest is 15.3.0), upgrade is highly recommended!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions