tweak: utils and constants - frontend
This commit is contained in:
@@ -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,
|
||||
})
|
||||
8
client/src/constants/index.js
Normal file
8
client/src/constants/index.js
Normal 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,
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
7
client/src/utils/axios.js
Normal file
7
client/src/utils/axios.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import axios from 'axios'
|
||||
import { BACKEND_URL } from '../constants'
|
||||
|
||||
// axios configuration
|
||||
export default axios.create({
|
||||
baseURL: BACKEND_URL,
|
||||
})
|
||||
Reference in New Issue
Block a user