Skip to content

Commit

Permalink
add .env files (#9767)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronanc-tigera authored Feb 3, 2025
1 parent edd2365 commit ce0598a
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions oss-ui/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_API_URL="https://localhost:3000"
1 change: 1 addition & 0 deletions oss-ui/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
APP_API_URL="/prospector"
1 change: 1 addition & 0 deletions oss-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"@testing-library/react": "^16.1.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.14",
"@types/node": "^22.12.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/react-router-dom": "^5.3.3",
Expand Down
5 changes: 4 additions & 1 deletion oss-ui/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { defineConfig } from '@rsbuild/core';
import { defineConfig, loadEnv } from '@rsbuild/core';
import { pluginReact } from '@rsbuild/plugin-react';
import { pluginTypeCheck } from '@rsbuild/plugin-type-check';

const { publicVars } = loadEnv({ prefixes: ['APP_'] });

export default defineConfig({
plugins: [pluginReact(), pluginTypeCheck()],
server: {
Expand All @@ -14,5 +16,6 @@ export default defineConfig({
entry: {
index: './src/main.tsx',
},
define: publicVars,
},
});
2 changes: 1 addition & 1 deletion oss-ui/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { objToQueryStr, QueryObject } from '@/libs/tigera/ui-components/utils';
import { ApiError } from '../types/api';

const API_URL = '/prospector';
const API_URL = process.env.APP_API_URL;

type ApiOptions = RequestInit & {
queryParams?: QueryObject;
Expand Down
2 changes: 1 addition & 1 deletion oss-ui/src/features/flowLogs/api/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe('useFlowLogs', () => {
it('should call api get with the expected params', () => {
renderHookWithQueryClient(useFlowLogs);

expect(api.get).toHaveBeenCalledWith('flow-logs', {
expect(api.get).toHaveBeenCalledWith('flows', {
queryParams: undefined,
});
});
Expand Down
5 changes: 5 additions & 0 deletions oss-ui/src/types/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare namespace NodeJS {
interface ProcessEnv {
APP_API_URL: string;
}
}
7 changes: 7 additions & 0 deletions oss-ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1286,6 +1286,13 @@
dependencies:
undici-types "~6.20.0"

"@types/node@^22.12.0":
version "22.12.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.12.0.tgz#bf8af3b2af0837b5a62a368756ff2b705ae0048c"
integrity sha512-Fll2FZ1riMjNmlmJOdAyY5pUbkftXslB5DgEzlIuNaiWhXd00FhWxVC/r4yV/4wBb9JfImTu+jiSvXTkJ7F/gA==
dependencies:
undici-types "~6.20.0"

"@types/parse-json@^4.0.0":
version "4.0.2"
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.2.tgz#5950e50960793055845e956c427fc2b0d70c5239"
Expand Down

0 comments on commit ce0598a

Please sign in to comment.