From 5d0e7aeb22097c0e01f81877497cfc1baba6ac79 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 29 Nov 2020 16:21:35 -0600 Subject: [PATCH] configured axios base url for dynamic environments --- client/src/api/api.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/client/src/api/api.js b/client/src/api/api.js index 85c8536..2367339 100644 --- a/client/src/api/api.js +++ b/client/src/api/api.js @@ -1,5 +1,12 @@ import axios from "axios"; +/* +If serve static dev -> host = localhost:3000 +If concurrent dev -> host = localhost:5000 +If production -> host = 'https://lsu-it-support-demo.herokuapp.com/' +*/ +const PORT = process.env.PORT || 5000; +const HOST = process.env.HOST || `localhost:${PORT}` export default axios.create({ - baseURL: `http://localhost:3000/api/`, + baseURL: `http://${HOST}/api/`, });