tweak: utils and constants - frontend

This commit is contained in:
Ben Elferink
2021-10-27 19:26:02 +03:00
parent 75979bce3d
commit 8540360217
5 changed files with 17 additions and 10 deletions

View File

@@ -0,0 +1 @@
REACT_APP_BACKEND_URL = ""

View File

@@ -1,9 +0,0 @@
import axios from 'axios'
// api url (where your serve is hosted at)
export const backendUrl = 'http://localhost:8080'
// axios configuration
export default axios.create({
baseURL: backendUrl,
})

View File

@@ -0,0 +1,8 @@
const {
// api url (where your server is hosted at)
REACT_APP_BACKEND_URL: BACKEND_URL = 'http://localhost:8080',
} = process.env
export {
BACKEND_URL,
}

View File

@@ -1,5 +1,5 @@
import { createContext, useContext, useState, useEffect } from 'react'
import axios from '../api'
import axios from '../utils/axios'
// init context
const AuthContext = createContext()

View File

@@ -0,0 +1,7 @@
import axios from 'axios'
import { BACKEND_URL } from '../constants'
// axios configuration
export default axios.create({
baseURL: BACKEND_URL,
})