Skip to content

Commit 3a4f6f1

Browse files
committed
Fix testnet faucet for localhost
1 parent 19d24c5 commit 3a4f6f1

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/TestnetFaucet.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import { defineComponent, ref, Ref } from '@vue/composition-api';
2121
import { CircleSpinner, CrossIcon } from '@nimiq/vue-components';
2222
import { LocaleMessage } from 'vue-i18n';
23-
import { MAINNET_ORIGIN } from '../lib/Constants';
23+
import { MAINNET_ORIGIN, TESTNET_ORIGIN } from '../lib/Constants';
2424
2525
type FaucetInfoResponse = {
2626
network: 'test' | 'main',
@@ -70,7 +70,10 @@ export default defineComponent({
7070
const faucetInfoPromise = fetch(`${FAUCET_URL}/info`)
7171
.then((res) => res.json() as Promise<FaucetInfoResponse>)
7272
.then((faucet) => {
73-
const expectedNetwork = window.location.origin === MAINNET_ORIGIN ? 'main' : 'test';
73+
const expectedNetwork = {
74+
[MAINNET_ORIGIN]: 'main',
75+
[TESTNET_ORIGIN]: 'test',
76+
}[window.location.origin];
7477
7578
if (faucet.network !== expectedNetwork) {
7679
unavailableMsg.value = context.root.$t('Faucet unavailable (wrong network)');

src/lib/Constants.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ export const ENV_TEST = 'test';
1212
export const ENV_DEV = 'dev';
1313

1414
export const MAINNET_ORIGIN = 'https://wallet.nimiq.com';
15-
export const TESTNET_ORIGIN = 'https://wallet.nimiq-testnet.com';
15+
export const TESTNET_ORIGIN = window.location.hostname === 'localhost'
16+
? 'http://localhost:8081'
17+
: 'https://wallet.nimiq-testnet.com';
1618

1719
export const FIAT_CURRENCY_DENYLIST = [
1820
'BDT', 'BHD', 'BMD', 'KWD', 'LKR', 'MMK', 'SAR',

0 commit comments

Comments
 (0)