Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,11 @@ npm install
npm run dev
```

The app runs against the live testnet API by default.
The app runs against the live testnet API by default. To use a different backend, set `VITE_API_BASE_URL`:

```bash
VITE_API_BASE_URL=http://localhost:3000/api/v1 npm run dev
```

No local backend setup is required to start contributing to the frontend.

Expand Down
30 changes: 30 additions & 0 deletions src/constants/config.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { afterEach, describe, expect, it, vi } from 'vitest'

const DEFAULT_API_BASE_URL = 'https://stepfi-api.onrender.com/api/v1'

async function importConfig() {
vi.resetModules()
return import('./config')
}

describe('config', () => {
afterEach(() => {
vi.unstubAllEnvs()
})

it('uses the live testnet API by default', async () => {
vi.stubEnv('VITE_API_BASE_URL', undefined)

const { API_BASE_URL } = await importConfig()

expect(API_BASE_URL).toBe(DEFAULT_API_BASE_URL)
})

it('uses VITE_API_BASE_URL when provided', async () => {
vi.stubEnv('VITE_API_BASE_URL', 'http://localhost:3000/api/v1')

const { API_BASE_URL } = await importConfig()

expect(API_BASE_URL).toBe('http://localhost:3000/api/v1')
})
})
2 changes: 1 addition & 1 deletion src/constants/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const API_BASE_URL =
'https://stepfi-api.onrender.com/api/v1'
import.meta.env.VITE_API_BASE_URL ?? 'https://stepfi-api.onrender.com/api/v1'

export const STELLAR_NETWORK = 'TESTNET'

Expand Down