Next.js 14 Vercel + Stripe: Error occurred in the Server Components render. Message is omitted in production builds to avoid leaking sensitive details

utils/actions/stripe.ts is a file that holds my stripe checkout function and manageBilling (for cancelling subscription)

"use server";
import Stripe from "stripe";

const stripe = new Stripe(process.env.STRIPE_SK!);

export default async function checkout(email:string, priceId:string, redirectTo:string) {
    return JSON.stringify(
        await stripe.checkout.sessions.create({
        success_url:redirectTo || process.env.SITE_URL,
        cancel_url: process.env.SITE_URL,
        customer_email: email,
        line_items:[{price:priceId, quantity:1}],
        mode: 'subscription'
    })
)
}

export async function manageBilling(customer_id:string){
    return JSON.stringify(await stripe.billingPortal.sessions.create({
        customer: customer_id,
        return_url: process.env.SITE_URL,
    }))
}

I then use it in my ProfileCard.tsx which I put in my /pricing route (a client component). The “Cancel your subscription” button calls the handleBilling function which uses manageBilling.

import useUser from "@/app/hook/useUser";
import { manageBilling } from "@/utils/actions/stripe";

export default function ProfileCard() {
    const{data:user, isLoading} = useUser();
    if(isLoading) return <></>


    const handleBilling = async () => {
        try {
            if (user?.subscriptions?.customer_id) {
                const data = JSON.parse(await manageBilling(user?.subscriptions?.customer_id));
                window.location.href = data.url;
            }
        } catch (error) {
            console.error("Billing error:", error);
            alert("An error occurred while managing your billing. Please try again later.");
        }
    };

    return(
     <div className="flex items-start card bg-base-100 border border-gray-600 shadow-2xl h-[350px] w-[500px] sm:max-md:w-[350px]">
        <p className="text-2xl font-semibold ml-48 sm:max-md:ml-32 mt-3 italic underline">User info</p>
        <div className="card-body mt-3">
            <div className="space-y-3">
                <p className="text-xl underline">Email: {user?.email}</p>
                {user?.subscriptions?.end_at? 
                    <>
                    <p className="text-xl font-semibold text-green-600">
                        User type: Active
                    </p>
                    <p className="text-lg">
                    Subscription end: {""}
                    {new Date(user?.subscriptions?.end_at).toDateString()}
                </p>
                </>
                :
                <>
                <p className="text-xl font-semibold text-gray-300">
                    User type: Inactive
                </p>
                <p className="text-lg">
                    Subscription end: Inactive
                </p>
                </>
                }
                <p className="text-lg">
                    Created at: {new Date(user?.created_at!).toDateString()}
                </p>
            </div>
            {user?.subscriptions?.customer_id &&
                <div className="mt-8 flex items-center justify-center ml-32"> 
                <button className="btn btn-error rounded-md" onClick={handleBilling}>Cancel your subscription</button>
                </div>
                }
         </div>
        </div>
    );
}

The problem is that whenever I click the “Cancel your subscription” button, I get the following error in the console:

Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.

This only happens while deployed on vercel, it worked perfectly on localhost. Everything else stripe related works (checkouts), I don’t get why this doesn’t.

Vercel logs show literally no issue when pressing the button (shows the green code 200 saying ok).

As an absolute beginner trying my best at a full stack website, I am completely stuck, no idea what I can try to do to fix this. I have my STRIPE_SK in my .env.local, and checkouts work perfectly with that same key.

New contributor

Dyrone is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật