# Production Environment





Your project runs in two places. The **sandbox** is development: the agent builds and tests there, using the values in your project's `.env` and the [Secrets](/docs/features/secrets) tab. **Vercel or Railway** is production: your live app runs there, using the environment variables stored on that host.

The two should never share secrets. This page covers why, and what to do after every deploy.

## Why Production Needs Its Own Secrets [#why-production-needs-its-own-secrets]

<Cards className="grid-cols-1 sm:grid-cols-3">
  <Card title="Contain leaks" icon="<ShieldAlert />" description="Development keys pass through the sandbox, the terminal and the agent. If one leaks, production stays untouched." />

  <Card title="Keep test data out" icon="<FlaskConical />" description="A separate production database means test sign-ups, seed rows and experiments never mix with real users." />

  <Card title="Rotate independently" icon="<RotateCcw />" description="Replace a production key without breaking development, and the other way round." />
</Cards>

Payments make this concrete: development runs on **test** credentials, where no money moves. Production needs **live** credentials, which only you set, directly on your host.

<Callout type="error">
  Never commit `.env` to your repository or paste its values anywhere, including
  the chat. It holds your development secrets, and production reads its values
  from the host, not from a file.
</Callout>

## Rules for Every Variable [#rules-for-every-variable]

* **Keep secrets out of the browser.** Anything with a public prefix (`NEXT_PUBLIC_…` in Next.js, `VITE_…` in Vite) is visible to every visitor. Only public values, like a payment provider's key ID, belong there.
* **Document names, not values.** Keep a `.env.example` listing every variable name with empty values, so you and collaborators know what production needs.
* **Never log secrets.** Keep them out of console output, error messages and analytics.
* **Use the narrowest key.** When a provider offers restricted, read-only or scoped keys, use those instead of full-access ones.
* **Share through the host.** Give teammates access on Vercel or Railway instead of sending values over chat or email.

## How Publish Handles Variables [#how-publish-handles-variables]

Each deploy from Ideavo sends your project's current variables with it, and they replace matching variables on Vercel or Railway. That gets the first deploy running, but it also means your production values are overwritten on every deploy from Ideavo.

<Callout type="warn">
  After every deploy from Ideavo, check your production variables on Vercel or
  Railway and update them again.
</Callout>

## Updating Variables on Your Host [#updating-variables-on-your-host]

Open your host's environment variables, update the values, and redeploy so they take effect.

<Tabs defaultValue="vercel">
  <TabsList>
    <TabsTrigger value="vercel">
      <SiVercel />

       Vercel
    </TabsTrigger>

    <TabsTrigger value="railway">
      <SiRailway />

       Railway
    </TabsTrigger>
  </TabsList>

  <TabsContent value="vercel">
    <Steps>
      <Step>
        Open your project's **Settings → Environments** and choose **Production**.
      </Step>

      <Step>
        Update the values under **Environment Variables** ([Vercel's guide](https://vercel.com/docs/environment-variables)).
      </Step>

      <Step>
        Redeploy from **Deployments → ⋯ → Redeploy**.
      </Step>
    </Steps>
  </TabsContent>

  <TabsContent value="railway">
    <Steps>
      <Step>
        Open your project, then the **app** service's **Variables** tab. Ideavo
        sets variables on the service, not in Shared Variables.
      </Step>

      <Step>
        Update the values ([Railway's guide](https://docs.railway.com/guides/variables)).
      </Step>

      <Step>
        Click **Deploy** to apply the staged changes.
      </Step>
    </Steps>
  </TabsContent>
</Tabs>

Browser variables (`NEXT_PUBLIC_…` in Next.js, `VITE_…` in Vite) are built into the app, so they change only after a new build.

## Database in Production [#database-in-production]

Production needs its own database: ideally a new one, or at least a new [branch](https://neon.com/docs/introduction/branching) of your development database.

1. Create it and set its connection string as `DATABASE_URL` on your host.
2. Apply your schema to it with your project's migration command, pointed at the production database.
3. Repeat step 2 whenever a deploy changes the schema.

Never reset or seed the production database.

## Auth in Production [#auth-in-production]

If your app uses Better Auth, set these on your host:

* **`BETTER_AUTH_SECRET`**: a new random value, different from development. Generate one with `openssl rand -base64 32`. Changing it later signs every user out.
* **`BETTER_AUTH_URL`**: your production URL, such as `https://your-app.vercel.app` or your custom domain.
* **Social sign-in**: in each provider's console (Google, GitHub and so on), add your production callback URL, `https://<your domain>/api/auth/callback/<provider>`.

## Payments in Production [#payments-in-production]

Development payments run in test mode through Ideavo's connection. To accept real payments, you replace the test credentials with your own live keys on your host and register a separate live webhook. Ideavo never stores live credentials.

For Razorpay, follow the step-by-step guide in [Razorpay → Going Live](/docs/features/razorpay#going-live).

## After Every Deploy [#after-every-deploy]

Run through these in order, top to bottom:

<Steps>
  <Step>
    **Restore production values.** The deploy replaced them with development
    ones, so set them again on your host, and make sure every variable your app
    needs is there.
  </Step>

  <Step>
    **Migrate the database.** If the schema changed, apply the migrations to the
    production database.
  </Step>

  <Step>
    **Check URLs.** Every variable that holds a URL, such as `BETTER_AUTH_URL`,
    sign-in callbacks and webhook endpoints, points at the live domain,
    including a custom domain.
  </Step>

  <Step>
    **Check payments.** Live keys are set, and the live webhook is registered.
  </Step>

  <Step>
    **Try it live.** Sign in and complete your app's main flow on the live URL.
  </Step>
</Steps>

## If a Secret Leaks [#if-a-secret-leaks]

A secret is leaked the moment it lands somewhere it shouldn't: a commit, a chat, a screenshot, a public log. Deleting it from there doesn't make it safe, because it may already be copied.

<Steps>
  <Step>
    **Revoke it at the provider first.** Generate a new key and delete the old
    one, for example regenerate API keys in the Razorpay Dashboard or reset the
    database password in Neon.
  </Step>

  <Step>
    **Set the new value on your host** and redeploy. For a development secret,
    update it in the [Secrets](/docs/features/secrets) tab instead.
  </Step>

  <Step>
    **Check for misuse.** Look through the provider's logs for activity you
    don't recognise, such as unexpected payments or database access.
  </Step>
</Steps>

<Callout type="info">
  Rotating `BETTER_AUTH_SECRET` signs every user out. That's expected: it
  invalidates any session made with the leaked secret.
</Callout>

### FAQ [#faq]

<Accordions>
  <Accordion title="Why did my production variables change back?">
    Each deploy from Ideavo sends your project's current variables and replaces
    matching ones on your host. Update your production values again after every
    deploy from Ideavo.
  </Accordion>

  <Accordion title="Do I need to redeploy after changing a variable?">
    Yes. Vercel applies variables to new deployments only, and Railway applies
    them when you deploy the staged changes. Variables the browser reads also
    need a new build.
  </Accordion>

  <Accordion title="Can development and production share a database?">
    They can, but they shouldn't. Test data ends up next to real users, and a
    bad migration during development breaks your live app.
  </Accordion>

  <Accordion title="Is my .env pushed to GitHub?">
    No. Secrets are never committed to your repository. Keep `.env` in
    `.gitignore` if you work on the code outside Ideavo.
  </Accordion>

  <Accordion title="Where do I find my production URL?">
    In the Publish panel after a successful deploy, or on your project's page
    on Vercel or Railway.
  </Accordion>
</Accordions>
