Skip to content

Astro: PUBLIC_CLERK_PUBLISHABLE_KEY cannot be changed after build #7841

@Gr3q

Description

@Gr3q

Preliminary Checks

Reproduction

http://github.com/clerk/clerk-astro-quickstart

Publishable key

pk_test_cHJvLWNvd2JpcmQtNTcuY2xlcmsuYWNjb3VudHMuZGV2JA

Description

PUBLIC_CLERK_PUBLISHABLE_KEY can't be read from the runtime environment, it is baked in when the astro app is built (tbh all of the variables starting with PUBLIC_ but I'm going to ignore those here)

Steps to reproduce:

  1. Set up your .env with values placeholder for each variable - Optional, you can leave them empty too
  2. Run pnpm build
  3. Run PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_cHJvLWNvd2JpcmQtNTcuY2xlcmsuYWNjb3VudHMuZGV2JA node dist/server/entry.mjs
  4. Open the page (http://localhost:4321)

Expected behavior:

The server doesn't throw publishable key errors.

Actual behavior:

It does.

Environment

System:
    OS: macOS 26.2
    CPU: (12) arm64 Apple M4 Pro
    Memory: 62.94 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.13.0 - /opt/homebrew/opt/node@24/bin/node
    npm: 11.6.2 - /opt/homebrew/opt/node@24/bin/npm
    pnpm: 10.28.1 - /opt/homebrew/opt/node@24/bin/pnpm
    bun: 1.3.3 - /Users/attilagreguss/.bun/bin/bun
  Browsers:
    Chrome: 144.0.7559.133
    Firefox: 147.0.2
    Safari: 26.2
  npmPackages:
    @astrojs/check: ^0.9.6 => 0.9.6 
    @astrojs/node: ^9.5.2 => 9.5.2 
    @clerk/astro: ^2.16.17 => 2.16.17 
    astro: ^5.17.1 => 5.17.1 
    prettier: ^3.3.2 => 3.3.2 
    prettier-plugin-astro: ^0.14.0 => 0.14.0 
    typescript: ^5.5.3 => 5.5.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageA ticket that needs to be triaged by a team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions