Skip to content

Commit

Permalink
Turn NEXT_PUBLIC_REFLECT_SERVER into a template (😳).
Browse files Browse the repository at this point in the history
  • Loading branch information
aboodman committed Feb 1, 2024
1 parent 8533c75 commit 5b9f1d1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/util/host.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
export const reflectServer = process.env.NEXT_PUBLIC_REFLECT_SERVER ?? "";
export const reflectServer = process.env.NEXT_PUBLIC_REFLECT_SERVER
? applyTemplateWithEnvVars(process.env.NEXT_PUBLIC_REFLECT_SERVER)
: "";

function applyTemplateWithEnvVars(template: string) {
const f = new Function(...Object.keys(process.env), `return \`${template}\``);
return f(...Object.values(process.env));
}

0 comments on commit 5b9f1d1

Please sign in to comment.