Skip to content

[Bug?]: 2.0.0-alpha.2 - process.env not available in server functions #2113

@create-signal

Description

@create-signal

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Current behavior 😯

Loving the look of V2! I've noticed that when starting a project in dev mode with vite dev, none of the Private Environment Variables (those not prepended with VITE_) are available to Server Functions

.env

MY_SECRET=hello

routes/index.tsx

import { createAsync } from "@solidjs/router";

const myServerFn = async () => {
    "use server";

    if (typeof process.env.MY_SECRET === "undefined") {
        return "MY_SECRET is undefined";
    }

    return "OK";
};

export default function Component() {
    const result = createAsync(myServerFn);
    return (
        <>{result()}</> //Shows "MY_SECRET is undefined"
    );
}

The documentation on Private Environment Variables suggests that this should be OK.

Expected behavior 🤔

process.envshould be available in dev mode

Steps to reproduce 🕹

Steps:

Context 🔦

No response

Your environment 🌎

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions