Skip to content

Commit 36fab33

Browse files
committed
chore: switch to process.env.VITE_API_URI until js/typescript refactored
1 parent 9c73574 commit 36fab33

5 files changed

Lines changed: 16 additions & 15 deletions

File tree

src/ui/apiBase.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const strip = (s: string) => s.replace(/\/+$/, '');
2+
/**
3+
* The base URL for API requests.
4+
*
5+
* Uses the `VITE_API_URI` environment variable if set, otherwise defaults to the current origin.
6+
* @return {string} The base URL to use for API requests.
7+
*/
8+
export const API_BASE = process.env.VITE_API_URI ? strip(process.env.VITE_API_URI) : '';

src/ui/components/Navbars/DashboardNavbarLinks.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ import { getUser } from '../../services/user';
1717
import axios from 'axios';
1818
import { getAxiosConfig } from '../../services/auth';
1919
import { UserData } from '../../../types/models';
20-
import { API_BASE } from '../../utils';
20+
21+
import { API_BASE } from '../../apiBase';
2122

2223
const useStyles = makeStyles(styles);
2324

src/ui/services/user.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import axios, { AxiosError, AxiosResponse } from 'axios';
22
import { getAxiosConfig, processAuthError } from './auth';
33
import { UserData } from '../../types/models';
4-
import { API_BASE } from '../utils';
4+
5+
import { API_BASE } from '../apiBase';
56

67
type SetStateCallback<T> = (value: T | ((prevValue: T) => T)) => void;
78

src/ui/utils.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,13 @@
11
import axios from 'axios';
22
import React from 'react';
33
import {
4-
SCMRepositoryMetadata,
4+
CommitData,
55
GitHubRepositoryMetadata,
66
GitLabRepositoryMetadata,
7-
CommitData,
7+
SCMRepositoryMetadata,
88
} from '../types/models';
99
import moment from 'moment';
1010

11-
const strip = (s: string) => s.replace(/\/+$/, '');
12-
13-
/**
14-
* The base URL for API requests.
15-
*
16-
* Uses the `VITE_API_URI` environment variable if set, otherwise defaults to the current origin.
17-
* @return {string} The base URL to use for API requests.
18-
*/
19-
export const API_BASE = import.meta.env.VITE_API_URI ? strip(import.meta.env.VITE_API_URI) : '';
20-
2111
/**
2212
* Retrieve a decoded cookie value from `document.cookie` with given `name`.
2313
* @param {string} name - The name of the cookie to retrieve

src/ui/views/Login/Login.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import CardFooter from '../../components/Card/CardFooter';
1313
import axios, { AxiosError } from 'axios';
1414
import logo from '../../assets/img/git-proxy.png';
1515
import { Badge, CircularProgress, Snackbar } from '@material-ui/core';
16-
import { API_BASE, getCookie } from '../../utils';
16+
import { getCookie } from '../../utils';
1717
import { useAuth } from '../../auth/AuthProvider';
18+
import { API_BASE } from '../../apiBase';
1819

1920
interface LoginResponse {
2021
username: string;

0 commit comments

Comments
 (0)