Rename API endpoints in frontend and nginx.conf to match blockstream

This commit is contained in:
wiz
2020-07-06 00:15:16 +09:00
parent 50ccdc424d
commit 4aca806b70
5 changed files with 36 additions and 44 deletions

View File

@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
import { Block, Transaction, Address, Outspend, Recent, Asset } from '../interfaces/electrs.interface';
import { StateService } from './state.service';
const API_BASE_URL = document.location.protocol + '//' + document.location.hostname + ':' + document.location.port + '/electrs';
const API_BASE_URL = '{network}/api';
@Injectable({
providedIn: 'root'
@@ -16,9 +16,9 @@ export class ElectrsApiService {
private httpClient: HttpClient,
private stateService: StateService,
) {
this.apiBaseUrl = API_BASE_URL;
this.apiBaseUrl = API_BASE_URL.replace('{network}', '');
this.stateService.networkChanged$.subscribe((network) => {
this.apiBaseUrl = API_BASE_URL + '/' + network;
this.apiBaseUrl = API_BASE_URL.replace('{network}', network ? '/' + network : '');
});
}