join us on Discord for support, updates, and all things Snap AR! See you there!
Environment Variables and Camera Kit Web
Hi Team,
Currently working on a Next.js project and was hoping to get the API keys working through environment variables.
I have found that anytime I set the API key "dynamically" camera kit throws "client.js:1 ConfigurationError: Unsafe apiToken"
I had this occur when I was working on an Angular project before as well.
My setup is as follows:
.env.development contains CAMERAKIT_APITOKEN = "[token key here]"
index.tsx contains const cameraKit: CameraKit = await bootstrapCameraKit({ apiToken: process.env.CAMERAKIT_APITOKEN!, });
It would be nice to use the environment variables instead of hard coding the token to work between staging and prod.
I assume it is set this way to not allow the token to change after compiling or something.
Any way to get it working?
Thanks, Alex
Answers
-
Solved,
Because my app is delivering the variable to the client it requires the prefix "NEXT_PUBLIC_" in front of the env variable.
1 -
@alex_doudnikov Thanks for closing the loop! My apologies for the delay as I'm catching up. Thanks again!
0