The package claims to work with the middleware.
Though, in my experience (see below), I could not get it to work. Considering the middleware is an Edge runtime, that probably makes sense. Is there some other mechanism to support this use case?
SERVER_ENV=server NEXT_PUBLIC_ENV=client_server next dev
import { env } from "next-runtime-env";
import { NextRequest, NextResponse } from "next/server";
export async function middleware(req: NextRequest) {
console.log("SERVER_ENV", env("SERVER_ENV));
console.log("NEXT_PUBLIC_ENV", env("NEXT_PUBLIC_ENV"));
[...]
}