This repo will help you reproduce the bug
git clone https://github.com/strofimo/cf-middleware-move-permanently.git
cd cf-middleware-move-permanently
npm i
npm run dev
# accessing http://localhost:3000 lead to 301 Moved Permanently
# ▲ Next.js 14.1.0
# - Local: http://localhost:3000
This is the expected behave for a next js app.
npm run preview
# accessing http://localhost:8788 lead to 307 Temporary Redirect
# [wrangler:inf] Ready on http://localhost:8788