fix dev access

This commit is contained in:
Владислав Чикалкин 2020-09-24 13:31:44 +03:00
parent 92909a19ed
commit 47660d8483
3 changed files with 11 additions and 14 deletions

View File

@ -51,7 +51,6 @@
"@types/cors": "^2.8.7",
"@types/express": "^4.17.7",
"@types/faker": "^5.1.0",
"@types/ip": "^1.1.0",
"@types/lodash": "^4.14.159",
"@types/morgan": "^1.9.1",
"@types/node": "^14.6.0",
@ -62,7 +61,6 @@
"dotenv": "^8.2.0",
"faker": "^5.1.0",
"http-proxy-middleware": "^1.0.5",
"ip": "^1.1.5",
"rimraf": "^3.0.2",
"webpack-node-externals": "^2.5.1"
},

View File

@ -1,5 +1,3 @@
import { address } from 'ip';
export const API_PORT = 3001;
export const API_URL = `http://${address()}:${API_PORT}`;
export const CLIENT_DEV_URL = 'http://localhost:3000';

View File

@ -1,22 +1,23 @@
import axios from "axios";
import React from "react";
import ReactDOM from "react-dom";
import App from "./client/App";
import "./index.css";
import * as serviceWorker from "./client/serviceWorker";
import { API_URL } from "./core/constants/urls";
import axios from 'axios';
import React from 'react';
import ReactDOM from 'react-dom';
import App from './client/App';
import './index.css';
import * as serviceWorker from './client/serviceWorker';
import { API_PORT } from './core/constants/urls';
const isDevelopmentMode = process.env.NODE_ENV === "development";
const isDevelopmentMode = process.env.NODE_ENV === 'development';
if (isDevelopmentMode) {
axios.defaults.baseURL = API_URL;
console.log(window.location);
axios.defaults.baseURL = `http://${window.location.hostname}:${API_PORT}`;
}
ReactDOM.render(
// <React.StrictMode>
<App />,
// </React.StrictMode>
document.getElementById("root")
document.getElementById('root'),
);
// If you want your app to work offline and load faster, you can change