Skip to content

Server Environment Variables Accessible on Initial Render (SSR) - Security Concern? #187

@dpnunez

Description

@dpnunez

On the initial render, it appears that server-side environment variables are accessible because Next.js performs Server-Side Rendering (SSR) for the first render. Is this not a security concern?

First render:

Image

my page is using "use client"

"use client";

import { env } from "next-runtime-env";

export default function Home() {
  return <pre>{JSON.stringify(env("HOME"), null, 2)}</pre>;
}

Second render:

Image

Repo to reproduce it:https://github.com/dpnunez/runtime-env

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions