Deploy fails because secrets are not available during yarn build

My yarn build step is failing because env variables that are coming from secrets are missing.
I was able to deploy without an issue two days ago. I have also noticed flyctl secrets import not working as well.

fly secrets aren’t available at build time, they are runtime env variables. Are you sure you were able to reference them at build time before?

Yes I was able to reference them during build here:

const supabaseAdmin = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL || “”,
process.env.SUPABASE_SERVICE_ROLE_KEY || “”,
{auth: {persistSession: false}}
);

Now I get:

  • info Collecting page data …Error: supabaseKey is required.
    at new SupabaseClient (/home/alperen/snap-orders/.next/server/chunks/511.js:7450:33)

Putting below in dockerfile solved the issue.

ARG SUPABASE_SERVICE_ROLE_KEY=placeholder

That’s contradicting. You had to define a placeholder in order to get the build to work, that means the fly secrets aren’t available at build time. I’m confused on it was working before.

I am confused as well:)

Just be careful w/ your static pages, as it’s connecting to a non-existent database so those static pages would not be able to get any real data.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.