diff --git a/package.json b/package.json index b38687eb..0c2951e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-storefront", - "version": "7.7.1", + "version": "7.7.2", "description": "Build and deploy e-commerce progressive web apps (PWAs) in record time.", "module": "./index.js", "license": "Apache-2.0", diff --git a/src/props/fetchFromAPI.js b/src/props/fetchFromAPI.js index 920f73ae..1613cb16 100644 --- a/src/props/fetchFromAPI.js +++ b/src/props/fetchFromAPI.js @@ -25,9 +25,18 @@ import fetch from '../fetch' */ export default function fetchFromAPI({ req, asPath, pathname }) { const host = req ? process.env.API_HOST || req.headers['host'] : '' - const protocol = req ? (host.startsWith('localhost') ? 'http://' : 'https://') : '' const [path, search] = asPath.split('?') + let protocol = '' + + if (req) { + protocol = 'https://' + + if (host.startsWith('localhost') || host === '127.0.0.1') { + protocol = 'http://' + } + } + let uri = `/api${path.replace(/\/$/, '')}` if (search) {