Next.js Discord

Discord Forum

Can't use absolute paths on server

Unanswered
ᵗʰᵉ Nexus posted this in #help-forum
Open in Discord
I'm using a package that requires me to pass the absolute path of a certificate. It works fine on my local machine, but on Vercel, the absolute path doesn't work as expected. Is there a way to resolve this?

"use server";

import url from "url";
import path from "path";
import Gerencianet from "gn-api-sdk-typescript";

const certPath = url.pathToFileURL(
    path.join(
        process.cwd(),
        process.env.VERCEL_ENV == "production"
            ? "/cert/production.p12"
            : "/cert/development.p12"
    )
);

const gn = new Gerencianet({
    sandbox: process.env.VERCEL_ENV == "development" ? true : false,
    client_id: process.env.EFI_CLIENT_ID as string,
    client_secret: process.env.EFI_SECRET as string,
    certificate: certPath,

// ...
});

4 Replies

you want that as a server action? as by putting "use server" that is what occures...
@riský you want that as a server action? as by putting "use server" that is what occures...
but if I don't put "use server", I can't even import
;-;