-
Notifications
You must be signed in to change notification settings - Fork 70
Closed
Labels
Description
Describe the bug
When trailingSlash
is enabled in next.config.js
, requests to the Next optimization route (/_next/image
) fail with a 500 Internal Server Error using opennextjs-cloudflare build && opennextjs-cloudflare preview
(as well as when deployed on Workers). Below is a stack trace with some relevant snippets.
First Request
✘ [ERROR] ⨯ EvalError: Code generation from strings disallowed for this context
at [object Object]
at deprecate.wrapfunction [as function]
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:279:729)
at 228
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:282:16131)
at __nccwpck_require__2
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:292:36599)
at null.<anonymous>
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:292:36750)
at .open-next/server-functions/default/node_modules/next/dist/compiled/send/index.js
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:292:36792)
at null.<anonymous>
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:2:679)
at .open-next/server-functions/default/node_modules/next/dist/server/serve-static.js
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:292:37303)
at null.<anonymous>
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:2:679)
at
.open-next/server-functions/default/node_modules/next/dist/server/image-optimizer.js
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:293:105209)
[wrangler:info] GET /_next/image/ 500 Internal Server Error (40ms)
Successive Requests
✘ [ERROR] ⨯ TypeError: ImageOptimizerCache is not a constructor
at NextNodeServer.handleNextImageRequest
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:297:15836)
at Server3.normalizeAndAttachMetadata
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:23:28821)
at NextNodeServer.handleRequestImpl
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:24:18934)
at async processRequest
(file:///Users/colby/code/toolbox/.open-next/server-functions/default/handler.mjs:313:48763)
at null.<anonymous> (async
file:///Users/colby/code/toolbox/.wrangler/tmp/dev-n0E6Fh/worker.js:3323:5)
at null.<anonymous> (async
file:///Users/colby/code/toolbox/.wrangler/tmp/dev-n0E6Fh/worker.js:3096:16)
[wrangler:info] GET /_next/image/ 500 Internal Server Error (5ms)
This appears to happen for any image regardless of format, size, name, or other properties. Let me know if you need any more info to help diagnose, debug, or reproduce this.
Steps to reproduce
- Create a new next application (eg:
npx create-next-app image-testing
) - Install
@opennextjs/cloudflare
,wrangler
dev dependencies. - Add
"preview": "opennextjs-cloudflare build && opennextjs-cloudflare preview"
script topackage.json
. - Within the pages router, use the
<Image>
component with an imported image. - Run
npm run preview
and visit the page.
Expected behavior
Image is rendered the same as it is within next dev
, returning a 200 status code.
@opennextjs/cloudflare version
1.8.0
Wrangler version
4.34.0
next info output
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:30 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6020
Available memory (MB): 32768
Available CPU cores: 12
Binaries:
Node: 22.15.0
npm: 11.4.1
Yarn: N/A
pnpm: N/A
Relevant Packages:
next: 15.5.2 // Latest available version is detected (15.5.2).
eslint-config-next: 15.5.2
react: 19.1.1
react-dom: 19.1.1
typescript: 5.9.2
Next.js Config:
output: N/A
Additional context
No response