From 1b7d730ec9b9a7e66f0a301ab7e5cbac88136088 Mon Sep 17 00:00:00 2001 From: Jonathan Howard Date: Sat, 19 Oct 2024 15:14:51 -0700 Subject: [PATCH] Protect API keys from getting published to Github --- README.md | 3 ++- config.ts | 2 +- sample.env.local | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 sample.env.local diff --git a/README.md b/README.md index f3b4ebd..cf607e4 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,8 @@ yarn create next-app account-kit-app -e https://github.com/avarobinson/account-k ### Get you alchemy api key - Create a new embedded accounts configuration for an alchemy app in your [dashboard](https://dashboard.alchemy.com/accounts) -- Replace the api key in the config.ts file +- Copy sample.env.local to .env.local +- Replace the environment variable with your new Account Kit config's API key ### Run the app diff --git a/config.ts b/config.ts index a132ffb..25b26ff 100644 --- a/config.ts +++ b/config.ts @@ -29,7 +29,7 @@ const uiConfig: AlchemyAccountsUIConfig = { export const config = createConfig( { - transport: alchemy({ apiKey: "ALCHEMY_API_KEY" }), // TODO: add your Alchemy API key - https://dashboard.alchemy.com/accounts + transport: alchemy({ apiKey: process.env.NEXT_PUBLIC_ALCHEMY_API_KEY }), // TODO: add your Alchemy API key to .env.local - https://dashboard.alchemy.com/accounts chain: sepolia, ssr: true, // more about ssr: https://accountkit.alchemy.com/react/ssr storage: cookieStorage, // more about persisting state with cookies: https://accountkit.alchemy.com/react/ssr#persisting-the-account-state diff --git a/sample.env.local b/sample.env.local new file mode 100644 index 0000000..27fbdfd --- /dev/null +++ b/sample.env.local @@ -0,0 +1 @@ +NEXT_PUBLIC_ALCHEMY_API_KEY="ALCHEMY_API_KEY"