Last active
April 13, 2024 00:02
-
-
Save vanessabrazuna/82cf9ef37f192270fce277aa5f89b144 to your computer and use it in GitHub Desktop.
env
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from 'axios' | |
import { env } from '@/env' | |
export const api = axios.create({ | |
baseURL: env.VITE_API_URL, | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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