Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/universal/utils/fetching.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ export function parseJSON(response) {
}

export function hostUrl() {
const host = process.env.HOST;
const protocol = process.env.PROTOCOL;
const port = process.env.PORT;
return `${protocol}://${host}:${port}`;
if (typeof window !== 'undefined' && window.location) {
const {origin, protocol, host} = window.location;
return origin || `${protocol}//${host}`;
}
return 'http://localhost:3000';
}

export function postJSON(route, obj) {
Expand Down
5 changes: 0 additions & 5 deletions webpack/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,6 @@ export default {
'__PRODUCTION__': false,
'process.env.NODE_ENV': JSON.stringify('development')
}),
new webpack.EnvironmentPlugin([
'PROTOCOL',
'HOST',
'PORT'
]),
new HappyPack({
loaders: ['babel'],
threads: 4
Expand Down
5 changes: 0 additions & 5 deletions webpack/webpack.config.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,6 @@ export default {
'__PRODUCTION__': true,
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.EnvironmentPlugin([
'PROTOCOL',
'HOST',
'PORT'
]),
new HappyPack({
loaders: ['babel'],
threads: 4
Expand Down