Skip to content

Commit

Permalink
fixed an issue with fetchFromAPI when fetching from 127.0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
markbrocato committed Mar 10, 2020
1 parent cdabb44 commit 9f5c88d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-storefront",
"version": "7.7.2",
"version": "7.7.3",
"description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.",
"module": "./index.js",
"license": "Apache-2.0",
Expand Down
8 changes: 6 additions & 2 deletions src/props/fetchFromAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function fetchFromAPI({ req, asPath, pathname }) {
if (req) {
protocol = 'https://'

if (host.startsWith('localhost') || host === '127.0.0.1') {
if (host.startsWith('localhost') || host.startsWith('127.0.0.1')) {
protocol = 'http://'
}
}
Expand All @@ -59,5 +59,9 @@ export default function fetchFromAPI({ req, asPath, pathname }) {
}
}

return fetch(`${protocol}${host}${uri}`, { headers }).then(res => res.json())
const url = `${protocol}${host}${uri}`

console.log('url', url)

return fetch(url, { headers }).then(res => res.json())
}

0 comments on commit 9f5c88d

Please sign in to comment.