diff --git a/docs/releases/v2.7.3.md b/docs/releases/v2.7.3.md index 9758f42e555828325155789ec99f724dde136b42..c871714212a11ea27d688ef4d54711ac4c086692 100644 --- a/docs/releases/v2.7.3.md +++ b/docs/releases/v2.7.3.md @@ -3,6 +3,7 @@ ## Bugfix - fixed matomo visitor counting (broke since 2.7.0 release) +- fixed sane url generation ## Under the hood diff --git a/e2e/checklist.md b/e2e/checklist.md index eef89d804006fd65b2cfadb59cc3d687cb78f714..d03d59b1f8424872c3c88efefa15b01a3b600ecd 100644 --- a/e2e/checklist.md +++ b/e2e/checklist.md @@ -65,6 +65,9 @@ - [ ] on hover, show correct region name(s) - [ ] whole mesh loads ## saneURL +- [ ] saneurl generation functions properly + - [ ] try existing key (human), and get unavailable error + - [ ] try non existing key, and get available - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/bigbrainGreyWhite) redirects to big brain - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/julichbrain) redirects to julich brain (colin 27) - [ ] [saneUrl](https://atlases.ebrains.eu/viewer-staging/saneUrl/whs4) redirects to waxholm v4 diff --git a/src/share/saneUrl/saneUrl.service.ts b/src/share/saneUrl/saneUrl.service.ts index 8f3af1f3d55fcb9baec57d44ddbbda76ac24c2df..c5d9849f760ed90b7197ef8206b53db55ab1025d 100644 --- a/src/share/saneUrl/saneUrl.service.ts +++ b/src/share/saneUrl/saneUrl.service.ts @@ -4,23 +4,27 @@ import { throwError } from "rxjs"; import { catchError, mapTo } from "rxjs/operators"; import { BACKENDURL } from 'src/util/constants' import { IKeyValStore, NotFoundError } from '../type' +import { DISABLE_PRIORITY_HEADER } from "src/util/priority" @Injectable({ providedIn: 'root' }) export class SaneUrlSvc implements IKeyValStore{ - public saneUrlRoot = `${BACKENDURL}saneUrl/` + public saneUrlRoot = `${BACKENDURL}go/` constructor( private http: HttpClient ){ - + if (!BACKENDURL) { + const loc = window.location + this.saneUrlRoot = `${loc.protocol}//${loc.hostname}${!!loc.port ? (':' + loc.port) : ''}${loc.pathname}go/` + } } getKeyVal(key: string) { return this.http.get<Record<string, any>>( `${this.saneUrlRoot}${key}`, - { responseType: 'json' } + { responseType: 'json', headers: { [DISABLE_PRIORITY_HEADER]: '1' } } ).pipe( catchError((err, obs) => { const { status } = err @@ -35,7 +39,8 @@ export class SaneUrlSvc implements IKeyValStore{ setKeyVal(key: string, value: any) { return this.http.post( `${this.saneUrlRoot}${key}`, - value + value, + { headers: { [DISABLE_PRIORITY_HEADER]: '1' } } ).pipe( mapTo(`${this.saneUrlRoot}${key}`) ) diff --git a/src/util/priority.ts b/src/util/priority.ts index ab703f76b14e1a299fa2ae017d81038a43c1c858..79ef1b043e4d5bb13a99e157995315e05e94b8d5 100644 --- a/src/util/priority.ts +++ b/src/util/priority.ts @@ -24,6 +24,8 @@ type Queue = { next: HttpHandler } +export const DISABLE_PRIORITY_HEADER = 'x-sxplr-disable-priority' + @Injectable({ providedIn: 'root' }) @@ -137,8 +139,11 @@ export class PriorityHttpInterceptor implements HttpInterceptor{ * Since the way in which serialization occurs is via path and query param... * body is not used. */ - if (this.disablePriority || req.method !== 'GET') { - return next.handle(req) + if (this.disablePriority || req.method !== 'GET' || !!req.headers.get(DISABLE_PRIORITY_HEADER)) { + const newReq = req.clone({ + headers: req.headers.delete(DISABLE_PRIORITY_HEADER) + }) + return next.handle(newReq) } const { urlWithParams } = req