Skip to content

Instantly share code, notes, and snippets.

@shd101wyy
Last active July 27, 2018 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shd101wyy/5540433b4a9f694b162afca52403f423 to your computer and use it in GitHub Desktop.
Save shd101wyy/5540433b4a9f694b162afca52403f423 to your computer and use it in GitHub Desktop.
testnet
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