Next.js Discord

Discord Forum

Server action leaking .env

Unanswered
Cynipid gall wasp posted this in #help-forum
Open in Discord
Cynipid gall waspOP
Ive got some router for generated presigned s3 urls.

router: https://pastebin.com/zSQ4MRjK (its not meant to be a public procedure)

I created an actions file like this:

"use server";

import { api } from "~/trpc/server";

export async function getUploadUrls(
...params: Parameters<typeof api.files.getUploadUrls>
) {
return await api.files.getUploadUrls(...params);
}


But when I import the actions on a client component I get an error.
I create this app using create-t3-app, I dont think I've changes anything about the default procedure.

2 Replies

Burmese
youd have to prefix that env var with NEXT_PUBLIC_ so it will be bundled at build time, and then included in the build
or if that feels weird, set up https://varlock.dev and then you mark items as being sensitive or not, without using a prefix