Add public envs

This commit is contained in:
2026-08-03 08:42:33 +01:00
parent 86ea86e7bd
commit 87948340b0
6 changed files with 58 additions and 12 deletions
@@ -70,12 +70,18 @@ export default async function genWebHTML({
const final_meta = _.merge(root_meta, page_meta);
// const public_envs = Object.keys(process.env).filter((e) =>
// e.startsWith(`NEXT_PUBLIC_`),
// );
const public_envs = Object.fromEntries(
Object.entries(process.env).filter(([k]) =>
k.startsWith("BUNEXT_PUBLIC_"),
),
);
const client_process = {
env: {},
env: {
NODE_ENV: dev ? "development" : "production",
...public_envs,
...global.CONFIG.public_envs,
},
};
let final_component = (
+4
View File
@@ -89,6 +89,10 @@ export type BunextConfig = {
* absolute), or a RegEx pattern.
*/
exclude_watch_patterns?: (string | RegExp)[];
/**
* Public environment variables to be passed to the client
*/
public_envs?: Record<string, string>;
};
export type BunextConfigMiddlewareParams = {