Last active
July 27, 2018 15:37
-
-
Save shd101wyy/5540433b4a9f694b162afca52403f423 to your computer and use it in GitHub Desktop.
testnet
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
const url = require("url"); | |
const BASE = "https://staging.iele.dev-mantis.iohkdev.io"; | |
function resolveApiUrl(relativeUrl) { | |
if (location.hostname.match(/localhost|127\.0\.0\.1/)) { | |
return url.resolve(BASE, relativeUrl); | |
} else { | |
return relativeUrl; | |
} | |
} | |
function resolveNodeUrl(port) { | |
if (location.hostname.match(/localhost|127\.0\.0\.1/)) { | |
return `${BASE}:${port}/`; | |
} else { | |
return location.protocol + `//` + location.hostname + `:${port}/`; | |
} | |
} | |
module.exports = { | |
resolveApiUrl, | |
resloveNodeUrl | |
} | |
// eg: | |
// resolveApiUrl("/remix/api") | |
// * local : https://staging.iele.dev-mantis.iohkdev.io/remix/api | |
// * remote: /remix/api | |
// resolveApiUrl("/transaction/") | |
// * local: https://staging.iele.dev-mantis.iohkdev.io/transaction/ | |
// * remote: /transaction/ | |
// resolveNodeUrl(8546) | |
// * local: https://staging.iele.dev-mantis.iohkdev.io:8546 | |
// * remote: ....:8546 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment