Closed mindmind closed 6 months ago
Not sure if it's the right way to go about it, but I found that setting
experimental: {
serverComponentsExternalPackages: ["next-runtime-env"],
}
seems to solve my issue.
Even though the issue was happening in API routes for me.
EDIT: This brought up new issues during build, which I solved like
export default (phase, { defaultConfig }) => {
if (phase !== "phase-development-server") {
return modifiedConfig;
}
return {
...modifiedConfig,
experimental: {
...modifiedConfig.experimental,
serverComponentsExternalPackages: [
...(modifiedConfig.experimental?.serverComponentsExternalPackages ?? []),
// we need this to be external (for now) during dev, but not during build
// https://github.com/expatfile/next-runtime-env/issues/123
"next-runtime-env",
],
},
};
};
@tefkah thanks
experimental: {
serverComponentsExternalPackages: ["next-runtime-env"],
}
solved the issue for me
This seems to only be related to the context approach. The suggested patch seems to work and we've updated the example in #127.
Hey everyone, today I upgraded my app with new 14.2.1 next.js version and found next-runtime-env crashing my app in the development runtime:
it works fine for me if I use next.js 14.1
I found that next.js swear on
import { createContext } from 'react';
and asks to add'use client'
for it. Maybe the reason is somewhere around.