Skip to content

Instantly share code, notes, and snippets.

@anomaly44
Created October 26, 2015 20:49
Show Gist options
  • Save anomaly44/7e0d3a951cd0b39d1d8b to your computer and use it in GitHub Desktop.
Save anomaly44/7e0d3a951cd0b39d1d8b to your computer and use it in GitHub Desktop.
function formatUrl(path) {
const adjustedPath = path[0] !== '/' ? '/' + path : path;
if (__SERVER__) {
// Prepend host and port of the API server to the path.
return 'http://localhost:' + config.apiPort + adjustedPath;
}
// Prepend `/api` to relative URL, to proxy to API server.
return '/api' + adjustedPath;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment