Skip to content

Instantly share code, notes, and snippets.

@vanessabrazuna
Last active April 13, 2024 00:02
Show Gist options
  • Save vanessabrazuna/82cf9ef37f192270fce277aa5f89b144 to your computer and use it in GitHub Desktop.
Save vanessabrazuna/82cf9ef37f192270fce277aa5f89b144 to your computer and use it in GitHub Desktop.
env
import { z } from 'zod'
const envSchema = z.object({
VITE_API_URL: z.string().url(),
})
export const env = envSchema.parse(import.meta.env)
command:
pnpm i dotenv -D
import 'dotenv/config'
import axios from 'axios'
import { env } from '@/env'
export const api = axios.create({
baseURL: env.VITE_API_URL,
})
Posterior node 20.6:
"scripts": {
"dev": " --env-file .env",
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment