u/Ramriez

▲ 8 r/nextjs

Why aren't API routes with environment variables treated as dynamic by default?

Given a robots.ts file with this content for example. If we do not add

export const dynamic = "force-dynamic"

then process.env.APP_ENV will resolve to undefined since Next.js treats this as a static route since it pre-renders it at build time.

But the whole idea behind environment variables are that they are at runtime.

import type { MetadataRoute } from "next"


export default function robots(): MetadataRoute.Robots {
  // Staging should not be indexed
  if (process.env.APP_ENV !== "production") {
    return { rules: [{ userAgent: "*", disallow: "/" }] }
  }


  return {
    rules: [{ userAgent: "*", allow: "/" }],
  }
}
reddit.com
u/Ramriez — 1 day ago

IaC or config.toml?

How are you guys handling infrastructure as code with Supabase? We could use config.toml, but it seems like that file only works for one Supabase instance since the project_id field selects on Supabase project.

We would like to handle both a staging and a production environment of Supabase.

Config as code with config.toml seems to work nicely when using Supabase branching, but does not seem to be so simple when having multiple projects.

We are considering using Pulumi for IaC.

reddit.com
u/Ramriez — 3 months ago