Skip to content

Commit

Permalink
Uses .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
devinvillarosa committed Jan 6, 2025
1 parent b2d2175 commit 8fcf00f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions ui-v2/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=http://localhost:4200/api
8 changes: 8 additions & 0 deletions ui-v2/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,12 @@ export default {
name: "@storybook/react-vite",
options: {},
},
/*
* 👇 The `config` argument contains all the other existing environment variables.
* Either configured in an `.env` file or configured on the command line.
*/
env: (config) => ({
...config,
VITE_API_URL: "http://localhost:6006/api",
}),
} satisfies StorybookConfig;
6 changes: 3 additions & 3 deletions ui-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "VITE_API_URL='http://localhost:4200/api' vite",
"dev": "vite",
"build": "tsc -b && vite build",
"test": "VITE_API_URL='http://localhost:4200/api' vitest",
"test": "vitest --mode staging",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"format:check": "biome check",
"format": "biome check --write",
"preview": "vite preview",
"service-sync": "uv run --with-editable ../. ../scripts/generate_oss_openapi_schema.py && npx openapi-typescript oss_schema.json -o src/api/prefect.ts && rm oss_schema.json",
"storybook": "VITE_API_URL='http://localhost:6006/api' storybook dev -p 6006",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion ui-v2/src/api/service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import createClient, { type Middleware } from "openapi-fetch";
import type { paths } from "./prefect.ts"; // generated by openapi-typescript

const BASE_URL = import.meta.env.VITE_API_URL as string;
const BASE_URL = import.meta.env.VITE_API_URL;

const throwOnError: Middleware = {
async onResponse({ response }) {
Expand Down
9 changes: 9 additions & 0 deletions ui-v2/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
/// <reference types="vite/client" />

interface ImportMetaEnv {
readonly VITE_API_URL: string;
// more env variables...
}

interface ImportMeta {
readonly env: ImportMetaEnv;
}

0 comments on commit 8fcf00f

Please sign in to comment.