#JTrain - Next.js config

1 messages · Page 1 of 1 (latest)

frank ravenBOT
languid wind
native peak
#

This is your front end / Stripe.js code throwing an error, correct?

#

Have you tried logging that NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY value to check that your env vars are set up as you expect/need?

#

(never share keys here, but check for yourself)

#

JTrain - Next.js config

languid wind
#

Hi synthrider, yes this is just for my front end. I am a new developer - this is a test implementation of stripe(test mode) for my portfolio. I just tried console logging and I am not getting anything.

native peak
#

not getting anything, meaning that key config is empty?

#

I'm not sure about how to configure next js, but i think theres a config file you need to use that ends up populating your environment variables

languid wind
#

Supposedly nextJS has support for environment variables built into it. I haven't had this issue before when using nextJS. Can I share my .env file with you? These are just test keys for a portfolio project.

native peak
#

Please do not DM -- if you want to share you can put it here but replace any sensitive secrets with placeholders, eg sk_test_123

languid wind
#

I only have those 2 keys as well as a SanityIO key that I am using for the backend.

#

My backend holds my product info and is working fine.

native peak
#

Are you following a specific guide/example?

#

Oh, perhaps not -- this is not suitable for secret keys

#

Note: environment variables specified in this way will always be included in the JavaScript bundle

#

Expose environment variables to the browser by prefixing with NEXT_PUBLIC_

#

Given that, you should not prefix your secret key with that

#

But also note it looks like you should be using .env.local for local testing, based on those doc