Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

Commit 98885ec

Browse files
committed
refac(various): server ip determined by OS
1 parent 1d53423 commit 98885ec

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

application/src/components/order-form/orderForm.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import React, { Component } from 'react';
22
import { Template } from '../../components';
33
import { connect } from 'react-redux';
4+
import { SERVER_IP } from '../../private';
45
import './orderForm.css';
56

6-
const ADD_ORDER_URL = "http://localhost:4000/api/add-order"
7+
const ADD_ORDER_URL = `${SERVER_IP}/api/add-order`
78

89
const mapStateToProps = (state) => ({
910
auth: state.auth,

application/src/components/view-orders/viewOrders.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React, { Component } from 'react';
22
import { Template } from '../../components';
3+
import { SERVER_IP } from '../../private';
34
import './viewOrders.css';
45

56
class ViewOrders extends Component {
@@ -8,7 +9,7 @@ class ViewOrders extends Component {
89
}
910

1011
componentDidMount() {
11-
fetch('http://localhost:4000/api/current-orders')
12+
fetch(`${SERVER_IP}/api/current-orders`)
1213
.then(response => response.json())
1314
.then(response => {
1415
if(response.success) {

application/src/private.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
const windowsPlatforms = ['Win32', 'Win64', 'Windows', 'WinCE'];
2+
3+
export const SERVER_IP = windowsPlatforms.indexOf(window.navigator.platform) < 0 ? 'http://localhost:4000' : 'http://192.168.99.100:4000';

application/src/redux/actions/authActions.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { LOGIN, LOGOUT } from './types';
2+
import { SERVER_IP } from '../../private'
23

34
const finishLogin = (email, token) => {
45
return {
@@ -12,7 +13,7 @@ const finishLogin = (email, token) => {
1213

1314
export const loginUser = (email, password) => {
1415
return (dispatch) => {
15-
fetch('http://localhost:4000/api/login', {
16+
fetch(`${SERVER_IP}/api/login`, {
1617
method: 'POST',
1718
body: JSON.stringify({
1819
email,

0 commit comments

Comments
 (0)