我想使用.env
文件中的变量,但我得到以下错误:
Uncaught (in promise) IntegrationError: Please call Stripe() with your publishable key. You used an empty string.
import Stripe from "stripe";
const stripe = new Stripe(process.env.NEXT_PUBLIC_STRIPE_SECRET_KEY);
.env
NEXT_PUBLIC_STRIPE_SECRET_KEY=***
在Next.js中,您应该在.env.local
文件中声明环境变量。
更多信息请查看官方文档。
然而,正如@juliomalves所建议的,你可以在.env.*
文件中声明你的环境变量,确保你尊重环境变量的加载顺序。