Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server env variables require additonal configuration / packages #480

Closed
OrJDev opened this issue Nov 26, 2022 · 3 comments · Fixed by #585
Closed

server env variables require additonal configuration / packages #480

OrJDev opened this issue Nov 26, 2022 · 3 comments · Fixed by #585
Labels
enhancement New feature or request

Comments

@OrJDev
Copy link
Contributor

OrJDev commented Nov 26, 2022

Currently enviroment variables that are not prefixed with VITE_ will not be loaded,
variables that are prefixed with VITE_ will be exposed to the client (import.meta.env),
what causing it so there is no such thing as server env variable in SolidStart.

this could easily be fixed using dotenv:

import solid from "solid-start/vite";
import dotenv from "dotenv";
import UnoCSS from "unocss/vite";
import { defineConfig } from "vite";
// @ts-expect-error no typing
import vercel from "solid-start-vercel";
  
export default defineConfig(() => {
  dotenv.config();
  return {
    plugins: [
          solid({ ssr: false, adapter: vercel({ edge: false }) }),
          UnoCSS(),
        ],
  };
});

but I think that it should not be handled in our end as SolidStart is a meta framework, and should be loading server variables by default.

@ryansolid
Copy link
Member

I agree. I imagine you have an idea of what this should look like. Is it just adding dotenv? Open to following your lead here as I've never really looked at this part in other meta frameworks. I've heard that SvelteKit does well here but that's about it.

@OrJDev
Copy link
Contributor Author

OrJDev commented Dec 24, 2022

just make sure to merge and test: examples/bare is where i tested it

#585

Also make sure to mark this as "done" in #576

@OrJDev OrJDev closed this as completed Dec 24, 2022
@OrJDev OrJDev reopened this Dec 24, 2022
@apatrida
Copy link

apatrida commented Aug 1, 2023

Are these build-time or runtime variables? i.e. if you do a production build and have not yet defined VITE_SOMETHING then will VITE_SOMETHING be available on the client if it is only defined before running the build?

SveltKit supports both static (build time) and dynamic (runtime) variables and docker containers, k8s will want to use runtime and not build time since secrets maybe are not baked into the container and are provided later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants