Skip to content

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

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