set api with REACT_APP_API
This commit is contained in:
parent
1222e7794c
commit
274ca42e7a
@ -3,6 +3,10 @@ import axios from 'axios'
|
|||||||
|
|
||||||
import { About, Tasks, Profile, Projects, Project, Navbar } from './components'
|
import { About, Tasks, Profile, Projects, Project, Navbar } from './components'
|
||||||
|
|
||||||
|
const api = process.env.REACT_APP_API || 'http://localhost:1337'
|
||||||
|
//console.log(process.env)
|
||||||
|
console.log('Using api at ' + api)
|
||||||
|
|
||||||
const defaultState = {
|
const defaultState = {
|
||||||
user: { name: 'Scott' },
|
user: { name: 'Scott' },
|
||||||
loading: true,
|
loading: true,
|
||||||
@ -32,13 +36,13 @@ class App extends React.Component {
|
|||||||
|
|
||||||
async fetchTasks() {
|
async fetchTasks() {
|
||||||
console.log('Fetching tasks...')
|
console.log('Fetching tasks...')
|
||||||
const { data } = await axios.get('/api/tasks')
|
const { data } = await axios.get(api + '/api/tasks')
|
||||||
await this.setState({ tasks: data })
|
await this.setState({ tasks: data })
|
||||||
}
|
}
|
||||||
|
|
||||||
async fetchProjects() {
|
async fetchProjects() {
|
||||||
console.log('Fetching projects...')
|
console.log('Fetching projects...')
|
||||||
const { data } = await axios.get('/api/projects')
|
const { data } = await axios.get(api + '/api/projects')
|
||||||
await this.setState({ projects: data })
|
await this.setState({ projects: data })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
const proxy = require('http-proxy-middleware')
|
|
||||||
|
|
||||||
module.exports = function(app) {
|
|
||||||
app.use(proxy('/api', { target: 'http://localhost:1337/' }))
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user