Skip to content

[BUG] @opennextjs/cloudflare openai connection error #681

Open
@wytxer

Description

@wytxer

Describe the bug

An error occurred when using the npm openai package: Error: Connection error.

Steps to reproduce

Minimal code example: https://github.com/wytxer/twilight-wildflower-feb3/tree/main

Add the OPENAI_API_KEY variable to the console, then run pnpm run deploy to deploy to a Cloudflare Worker.

Access the API in your browser: https://path.workers.dev/api/chat

An error appears in the logs shortly after.

The same business logic works fine when deployed to Vercel.

Expected behavior

Accessing /api/chat should return the conversation JSON.

@opennextjs/cloudflare version

1.0.4

Wrangler version

4.16.1

next info output

Using vars defined in .dev.vars

Operating System:
  Platform: darwin
  Arch: x64
  Version: Darwin Kernel Version 22.6.0: Sun Dec 17 22:18:09 PST 2023; root:xnu-8796.141.3.703.2~2/RELEASE_X86_64
  Available memory (MB): 16384
  Available CPU cores: 8
Binaries:
  Node: 18.19.1
  npm: 10.2.4
  Yarn: 1.22.22
  pnpm: 9.0.4
Relevant Packages:
  next: 15.3.2 // Latest available version is detected (15.3.2).
  eslint-config-next: N/A
  react: 19.1.0
  react-dom: 19.1.0
  typescript: N/A
Next.js Config:
  output: N/A

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtriage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions