Next.js: proces.env not available in next.config.js
marcellinocoTRIAL
6 months ago
I suspect that process.env is not loaded to my next.config.js, which is used for Next.js' image optimization remote patterns:
https://nextjs.org/docs/app/api-reference/components/image#remotepatterns
/** @type {import('next').NextConfig} */
const nextConfig = {
images: {
remotePatterns: [
{
protocol: process.env.NEXT_PUBLIC_MINIO_PROTOCOL,
hostname: process.env.NEXT_PUBLIC_MINIO_HOST,
port: process.env.NEXT_PUBLIC_MINIO_PORT,
pathname: "/assets/**",
},
],
},
};
In local it's working fine with the environment variables, and the build also went through. But when deploying via Railway I get this error when trying to load:
"url" parameter is not allowed
3 Replies
marcellinocoTRIAL
6 months ago
Hey, it's not an issue with the environment, as it's populated just fine in the next.config.js.
Turns out the port is causing confusion, so I just make the port an empty string for production environment.
Status changed to Solved brody • 6 months ago