Skip to content

Public environment variables misnamed in auto setup #646

@brandtam

Description

@brandtam

When following the setup instructions using the npm create sanity@latest init --env command in the app directory the script creates a .env file with the correct values for the environment variables. However the Names are incorrect.

It is created as:

app/.env

SANITY_PROJECT_ID="xxxxxxx"
SANITY_DATASET="production"

When it should be:

app/.env

PUBLIC_SANITY_PROJECT_ID="xxxxxxx"
PUBLIC_SANITY_DATASET="production"

This is due to the configuration that Public env variables have the Prefix of "PUBLIC_"

see the docs https://kit.svelte.dev/docs/modules#$env-static-public

Suggested Fix:
Easy way: Update the docs to inform people to edit the /app/.env file and prefix the generated variables with "PUBLIC_"
Hard way: add a flag to the install script to handle Framework specifics such as this. Something like npm create sanity@latest init --env --sveltekit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions