Public and private environment variables
Context:
.env
AZURE_STORAGE_CONNECTION_STRING=""
config
// app.config.ts
import { defineConfig } from "@tanstack/start/config";
import viteTsConfigPaths from "vite-tsconfig-paths";
export default defineConfig({
server: {
preset: "azure_functions",
},
vite: {
plugins: () => [
// this is the plugin that enables path aliases
viteTsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
},
});
I tried accessing the env var in a server function via
const connectionString = import.meta.env.AZURE_STORAGE_CONNECTION_STRING;
this doesn't work for some reason. returning undefined.
Also, how can I access an environment variable both in the server functions and in a client side?
.env
AZURE_STORAGE_CONNECTION_STRING=""
config
// app.config.ts
import { defineConfig } from "@tanstack/start/config";
import viteTsConfigPaths from "vite-tsconfig-paths";
export default defineConfig({
server: {
preset: "azure_functions",
},
vite: {
plugins: () => [
// this is the plugin that enables path aliases
viteTsConfigPaths({
projects: ["./tsconfig.json"],
}),
],
},
});
I tried accessing the env var in a server function via
const connectionString = import.meta.env.AZURE_STORAGE_CONNECTION_STRING;
this doesn't work for some reason. returning undefined.
Also, how can I access an environment variable both in the server functions and in a client side?