convert soft 404s to hard 404s in unfurler ssr
This commit is contained in:
parent
2f3e498906
commit
105cccf9b0
@ -47,6 +47,7 @@ export class BisqAddressComponent implements OnInit, OnDestroy {
|
|||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
@ -62,6 +63,7 @@ export class BisqAddressComponent implements OnInit, OnDestroy {
|
|||||||
(error) => {
|
(error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ export class BisqBlockComponent implements OnInit, OnDestroy {
|
|||||||
)
|
)
|
||||||
.subscribe((block: BisqBlock) => {
|
.subscribe((block: BisqBlock) => {
|
||||||
if (!block) {
|
if (!block) {
|
||||||
|
this.seoService.logSoft404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
@ -97,6 +98,7 @@ export class BisqBlockComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
caughtHttpError(err: HttpErrorResponse){
|
caughtHttpError(err: HttpErrorResponse){
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return of(null);
|
return of(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,11 +70,13 @@ export class BisqTransactionComponent implements OnInit, OnDestroy {
|
|||||||
catchError((txError: HttpErrorResponse) => {
|
catchError((txError: HttpErrorResponse) => {
|
||||||
console.log(txError);
|
console.log(txError);
|
||||||
this.error = txError;
|
this.error = txError;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
this.error = bisqTxError;
|
this.error = bisqTxError;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -103,6 +105,7 @@ export class BisqTransactionComponent implements OnInit, OnDestroy {
|
|||||||
this.isLoadingTx = false;
|
this.isLoadingTx = false;
|
||||||
|
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
|
this.seoService.logSoft404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
@ -157,6 +158,7 @@ export class AddressComponent implements OnInit, OnDestroy {
|
|||||||
(error) => {
|
(error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.isLoadingAddress = false;
|
this.isLoadingAddress = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -86,6 +86,7 @@ export class AssetComponent implements OnInit, OnDestroy {
|
|||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.isLoadingAsset = false;
|
this.isLoadingAsset = false;
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
@ -153,6 +154,7 @@ export class AssetComponent implements OnInit, OnDestroy {
|
|||||||
(error) => {
|
(error) => {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.isLoadingAsset = false;
|
this.isLoadingAsset = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
}),
|
}),
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('block-data-' + this.rawId);
|
this.openGraphService.fail('block-data-' + this.rawId);
|
||||||
this.openGraphService.fail('block-viz-' + this.rawId);
|
this.openGraphService.fail('block-viz-' + this.rawId);
|
||||||
return of(null);
|
return of(null);
|
||||||
@ -138,6 +139,7 @@ export class BlockPreviewComponent implements OnInit, OnDestroy {
|
|||||||
(error) => {
|
(error) => {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.isLoadingOverview = false;
|
this.isLoadingOverview = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('block-viz-' + this.rawId);
|
this.openGraphService.fail('block-viz-' + this.rawId);
|
||||||
this.openGraphService.fail('block-data-' + this.rawId);
|
this.openGraphService.fail('block-data-' + this.rawId);
|
||||||
if (this.blockGraph) {
|
if (this.blockGraph) {
|
||||||
|
@ -192,6 +192,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.error = err;
|
this.error = err;
|
||||||
this.isLoadingBlock = false;
|
this.isLoadingBlock = false;
|
||||||
this.isLoadingOverview = false;
|
this.isLoadingOverview = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@ -200,6 +201,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.error = err;
|
this.error = err;
|
||||||
this.isLoadingBlock = false;
|
this.isLoadingBlock = false;
|
||||||
this.isLoadingOverview = false;
|
this.isLoadingOverview = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
@ -215,6 +217,7 @@ export class BlockComponent implements OnInit, OnDestroy {
|
|||||||
this.error = err;
|
this.error = err;
|
||||||
this.isLoadingBlock = false;
|
this.isLoadingBlock = false;
|
||||||
this.isLoadingOverview = false;
|
this.isLoadingOverview = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
@ -61,6 +61,7 @@ export class PoolPreviewComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('pool-hash-' + this.slug);
|
this.openGraphService.fail('pool-hash-' + this.slug);
|
||||||
return of([slug]);
|
return of([slug]);
|
||||||
})
|
})
|
||||||
@ -70,6 +71,7 @@ export class PoolPreviewComponent implements OnInit {
|
|||||||
return this.apiService.getPoolStats$(slug).pipe(
|
return this.apiService.getPoolStats$(slug).pipe(
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
this.isLoading = false;
|
this.isLoading = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('pool-stats-' + this.slug);
|
this.openGraphService.fail('pool-stats-' + this.slug);
|
||||||
return of(null);
|
return of(null);
|
||||||
})
|
})
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core';
|
import { ChangeDetectionStrategy, Component, Inject, Input, LOCALE_ID, OnInit } from '@angular/core';
|
||||||
import { ActivatedRoute } from '@angular/router';
|
import { ActivatedRoute } from '@angular/router';
|
||||||
import { EChartsOption, graphic } from 'echarts';
|
import { EChartsOption, graphic } from 'echarts';
|
||||||
import { BehaviorSubject, Observable, timer } from 'rxjs';
|
import { BehaviorSubject, Observable, of, timer } from 'rxjs';
|
||||||
import { distinctUntilChanged, map, share, switchMap, tap } from 'rxjs/operators';
|
import { catchError, distinctUntilChanged, map, share, switchMap, tap } from 'rxjs/operators';
|
||||||
import { BlockExtended, PoolStat } from '../../interfaces/node-api.interface';
|
import { BlockExtended, PoolStat } from '../../interfaces/node-api.interface';
|
||||||
import { ApiService } from '../../services/api.service';
|
import { ApiService } from '../../services/api.service';
|
||||||
import { StateService } from '../../services/state.service';
|
import { StateService } from '../../services/state.service';
|
||||||
@ -59,10 +59,21 @@ export class PoolComponent implements OnInit {
|
|||||||
this.prepareChartOptions(data.map(val => [val.timestamp * 1000, val.avgHashrate]));
|
this.prepareChartOptions(data.map(val => [val.timestamp * 1000, val.avgHashrate]));
|
||||||
return [slug];
|
return [slug];
|
||||||
}),
|
}),
|
||||||
|
catchError(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
|
return of([slug]);
|
||||||
|
})
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
switchMap((slug) => {
|
switchMap((slug) => {
|
||||||
return this.apiService.getPoolStats$(slug);
|
return this.apiService.getPoolStats$(slug).pipe(
|
||||||
|
catchError(() => {
|
||||||
|
this.isLoading = false;
|
||||||
|
this.seoService.logSoft404();
|
||||||
|
return of(null);
|
||||||
|
})
|
||||||
|
);
|
||||||
}),
|
}),
|
||||||
tap(() => {
|
tap(() => {
|
||||||
this.loadMoreSubject.next(this.blocks[this.blocks.length - 1]?.height);
|
this.loadMoreSubject.next(this.blocks[this.blocks.length - 1]?.height);
|
||||||
|
@ -133,6 +133,7 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy {
|
|||||||
)
|
)
|
||||||
.subscribe((tx: Transaction) => {
|
.subscribe((tx: Transaction) => {
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('tx-data-' + this.txId);
|
this.openGraphService.fail('tx-data-' + this.txId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -182,6 +183,7 @@ export class TransactionPreviewComponent implements OnInit, OnDestroy {
|
|||||||
this.openGraphService.waitOver('tx-data-' + this.txId);
|
this.openGraphService.waitOver('tx-data-' + this.txId);
|
||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('tx-data-' + this.txId);
|
this.openGraphService.fail('tx-data-' + this.txId);
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.isLoadingTx = false;
|
this.isLoadingTx = false;
|
||||||
|
@ -193,8 +193,10 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
})
|
})
|
||||||
).subscribe((tx) => {
|
).subscribe((tx) => {
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
|
this.seoService.logSoft404();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.seoService.clearSoft404();
|
||||||
|
|
||||||
this.tx = tx;
|
this.tx = tx;
|
||||||
this.isCached = true;
|
this.isCached = true;
|
||||||
@ -286,9 +288,11 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
})
|
})
|
||||||
)
|
)
|
||||||
.subscribe((tx: Transaction) => {
|
.subscribe((tx: Transaction) => {
|
||||||
if (!tx) {
|
if (!tx) {
|
||||||
return;
|
this.seoService.logSoft404();
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
this.seoService.clearSoft404();
|
||||||
|
|
||||||
this.tx = tx;
|
this.tx = tx;
|
||||||
this.isCached = false;
|
this.isCached = false;
|
||||||
@ -340,6 +344,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
},
|
},
|
||||||
(error) => {
|
(error) => {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.isLoadingTx = false;
|
this.isLoadingTx = false;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -394,6 +399,7 @@ export class TransactionComponent implements OnInit, AfterViewInit, OnDestroy {
|
|||||||
this.waitingForTransaction = true;
|
this.waitingForTransaction = true;
|
||||||
}
|
}
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.isLoadingTx = false;
|
this.isLoadingTx = false;
|
||||||
return of(false);
|
return of(false);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ export class ChannelPreviewComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('channel-map-' + this.shortId);
|
this.openGraphService.fail('channel-map-' + this.shortId);
|
||||||
this.openGraphService.fail('channel-data-' + this.shortId);
|
this.openGraphService.fail('channel-data-' + this.shortId);
|
||||||
return of(null);
|
return of(null);
|
||||||
|
@ -38,6 +38,7 @@ export class ChannelComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError((err) => {
|
catchError((err) => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return [{
|
return [{
|
||||||
short_id: params.get('short_id')
|
short_id: params.get('short_id')
|
||||||
}];
|
}];
|
||||||
|
@ -50,6 +50,7 @@ export class GroupPreviewComponent implements OnInit {
|
|||||||
name: this.slug.replace(/-/gi, ' '),
|
name: this.slug.replace(/-/gi, ' '),
|
||||||
description: '',
|
description: '',
|
||||||
};
|
};
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('ln-group-map-' + this.slug);
|
this.openGraphService.fail('ln-group-map-' + this.slug);
|
||||||
this.openGraphService.fail('ln-group-data-' + this.slug);
|
this.openGraphService.fail('ln-group-data-' + this.slug);
|
||||||
return of(null);
|
return of(null);
|
||||||
@ -106,6 +107,7 @@ export class GroupPreviewComponent implements OnInit {
|
|||||||
};
|
};
|
||||||
}),
|
}),
|
||||||
catchError(() => {
|
catchError(() => {
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('ln-group-map-' + this.slug);
|
this.openGraphService.fail('ln-group-map-' + this.slug);
|
||||||
this.openGraphService.fail('ln-group-data-' + this.slug);
|
this.openGraphService.fail('ln-group-data-' + this.slug);
|
||||||
return of({
|
return of({
|
||||||
|
@ -81,6 +81,7 @@ export class NodePreviewComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('node-map-' + this.publicKey);
|
this.openGraphService.fail('node-map-' + this.publicKey);
|
||||||
this.openGraphService.fail('node-data-' + this.publicKey);
|
this.openGraphService.fail('node-data-' + this.publicKey);
|
||||||
return [{
|
return [{
|
||||||
|
@ -121,6 +121,7 @@ export class NodeComponent implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
return [{
|
return [{
|
||||||
alias: this.publicKey,
|
alias: this.publicKey,
|
||||||
public_key: this.publicKey,
|
public_key: this.publicKey,
|
||||||
|
@ -85,6 +85,7 @@ export class NodesPerISPPreview implements OnInit {
|
|||||||
}),
|
}),
|
||||||
catchError(err => {
|
catchError(err => {
|
||||||
this.error = err;
|
this.error = err;
|
||||||
|
this.seoService.logSoft404();
|
||||||
this.openGraphService.fail('isp-map-' + this.id);
|
this.openGraphService.fail('isp-map-' + this.id);
|
||||||
this.openGraphService.fail('isp-data-' + this.id);
|
this.openGraphService.fail('isp-data-' + this.id);
|
||||||
return of({
|
return of({
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { Title, Meta } from '@angular/platform-browser';
|
import { Title, Meta } from '@angular/platform-browser';
|
||||||
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
||||||
|
import { filter, map, switchMap } from 'rxjs';
|
||||||
import { StateService } from './state.service';
|
import { StateService } from './state.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -13,8 +15,22 @@ export class SeoService {
|
|||||||
private titleService: Title,
|
private titleService: Title,
|
||||||
private metaService: Meta,
|
private metaService: Meta,
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
|
private router: Router,
|
||||||
|
private activatedRoute: ActivatedRoute,
|
||||||
) {
|
) {
|
||||||
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
this.stateService.networkChanged$.subscribe((network) => this.network = network);
|
||||||
|
this.router.events.pipe(
|
||||||
|
filter(event => event instanceof NavigationEnd),
|
||||||
|
map(() => this.activatedRoute),
|
||||||
|
map(route => {
|
||||||
|
while (route.firstChild) route = route.firstChild;
|
||||||
|
return route;
|
||||||
|
}),
|
||||||
|
filter(route => route.outlet === 'primary'),
|
||||||
|
switchMap(route => route.data),
|
||||||
|
).subscribe((data) => {
|
||||||
|
this.clearSoft404();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setTitle(newTitle: string): void {
|
setTitle(newTitle: string): void {
|
||||||
@ -53,4 +69,14 @@ export class SeoService {
|
|||||||
ucfirst(str: string) {
|
ucfirst(str: string) {
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearSoft404() {
|
||||||
|
window['soft404'] = false;
|
||||||
|
console.log('cleared soft 404');
|
||||||
|
}
|
||||||
|
|
||||||
|
logSoft404() {
|
||||||
|
window['soft404'] = true;
|
||||||
|
console.log('set soft 404');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,15 @@ class Server {
|
|||||||
await page.waitForNetworkIdle({
|
await page.waitForNetworkIdle({
|
||||||
timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000,
|
timeout: config.PUPPETEER.RENDER_TIMEOUT || 3000,
|
||||||
});
|
});
|
||||||
let html = await page.content();
|
const is404 = await page.evaluate(async () => {
|
||||||
return html;
|
return !!window['soft404'];
|
||||||
|
});
|
||||||
|
if (is404) {
|
||||||
|
return '404';
|
||||||
|
} else {
|
||||||
|
let html = await page.content();
|
||||||
|
return html;
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (e instanceof TimeoutError) {
|
if (e instanceof TimeoutError) {
|
||||||
let html = await page.content();
|
let html = await page.content();
|
||||||
@ -258,7 +265,11 @@ class Server {
|
|||||||
result = await this.renderUnfurlMeta(rawPath);
|
result = await this.renderUnfurlMeta(rawPath);
|
||||||
}
|
}
|
||||||
if (result && result.length) {
|
if (result && result.length) {
|
||||||
res.send(result);
|
if (result === '404') {
|
||||||
|
res.status(404).send();
|
||||||
|
} else {
|
||||||
|
res.send(result);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.status(500).send();
|
res.status(500).send();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user