简体   繁体   中英

NEXJS stripe v3:1 Uncaught (in promise) IntegrationError: Missing value for Stripe(): apiKey should be a string

v3:1 Uncaught (in promise) IntegrationError: Missing value for Stripe(): apiKey should be a string.

I'm getting this error in next JS when trying to use stripe pre-built checkout.

.env.local (full key replaced with..... for stackoverflow)

NEXT_STRIPE_PUBLIC_KEY=pk_test_51Jl......

in function call

 const stripe = await loadStripe(process.env.NEXT_STRIPE_PUBLIC_KEY);

if I was to put the Publishable key directly in it works but from the env its not working for some reason

for example this would work

  const stripe = await loadStripe(`pk_test_51Jl...`);

I have the example below also and it didn't work.

const stripe = await loadStripe(`${process.env.NEXT_STRIPE_PUBLIC_KEY}`);

what I think is your key should be in quotation marks.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM