Last active
December 6, 2023 21:28
-
-
Save yushanwebdev/4513da94a4c24978678dd7708afcd111 to your computer and use it in GitHub Desktop.
An alternative mechanism for making available the env variables in the client (Inspired by Kent's suggestion in the custom scripts lesson of the EpicWeb.dev)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { getEnv } from '#app/utils/env.server.ts' | |
export async function loader() { | |
const envData = JSON.stringify(getEnv()) | |
const jsContent = `window.ENV = ${envData};` | |
return new Response(jsContent, { | |
headers: { | |
'Content-Type': 'application/javascript', | |
}, | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment