Skip to content

Commit

Permalink
fix(frontend): read BIOSTACK_API_HOST from process.env
Browse files Browse the repository at this point in the history
  • Loading branch information
berdal84 committed Jan 27, 2024
1 parent 2c805e5 commit 5faaadf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion frontend/src/app/utilities/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { useCallback } from "react";
import { useAppContext, useAppDispatchContext } from "../contexts/AppContext";
import { Page, Sample, SampleCreate, SampleUpdate } from "@/app/types";

// Declare a var to load environment variables non inlined
// (note: vars needs to start with NEXT_PUBLIC_ to be available in browser context at runtime)
const env = process.env

/**
* Create a new AXIOS instance to query the API
* See https://www.npmjs.com/package/axios
*/
const api = axios.create({
baseURL: 'http://localhost:8000/sample', // TODO: read from env vars
baseURL: `${env.NEXT_PUBLIC_BIOSTACK_API_HOST ?? 'http://localhost'}/sample`,
timeout: 3000,
headers: {
'Accept': 'application/json',
Expand Down

0 comments on commit 5faaadf

Please sign in to comment.