Skip to content

[BUG] Error: Dynamic require of "/.next/server/pages/api/hello.js" is not supported #442

@jeff-polls

Description

@jeff-polls

Describe the bug

500 error when pinging API routes in cloudflare preview mode, works when running next dev

I'm using the latest starter template with no changes:
yarn create cloudflare my-next-app --framework=next --experimental

I'm on a mac running Ventura, tried on node 20 and 22.

Steps to reproduce

yarn create cloudflare my-next-app --framework=next --experimental

Then run yarn preview

I can see the static page in the browser (although images and icons are broken), but when I try to ping the /api/hello endpoint I get a 500.

Expected behavior

The API routes in the example project should work

@opennextjs/cloudflare version

0.5.8

Wrangler version

3.114.0

next info output

✘ [ERROR] ⨯ Error: Dynamic require of "/.next/server/pages/api/hello.js" is not supported

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions