Created
February 26, 2021 03:24
-
-
Save arkumish/9efe092d648350a6e602f64ed4d0981a to your computer and use it in GitHub Desktop.
Api_root for multiple environment backend apis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let backendHost; | |
const hostname = window && window.location && window.location.hostname; | |
if(hostname === 'localhost') { | |
backendHost = 'http://localhost:5000'; //when frontend and backend are on the same server | |
} else if(hostname === 'yourWebsitename') { //eg markde.netlify.com | |
backendHost = 'backend_server_address'; //for backend hosted on different server not same as frontend | |
} else{ | |
backendHost = ''; | |
} | |
export const API_ROOT = `${backendHost}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment