Same problem here, we were somehow mixing old and new next version during the pipepline, due to a caching error... After we cleared the cache it worked.
Hint is looking at the middleware-manifest.json, you will see the env prop is empty...