-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GS] use the request's basePath when processing server-side result urls #76747
[GS] use the request's basePath when processing server-side result urls #76747
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
💚 Build SucceededBuild metricsdistributable file count
History
To update your PR or re-run it, just comment with: |
): BasePathAccessor => { | ||
const requestBasePath = basePath.get(request); | ||
return { | ||
prepend: (path) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it possible to reuse basePath.prepend
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK there is no way to only retrieve the request-specific (requestScopePath
) part of the basePath via the service, as get
returns the 'whole' base path:
kibana/src/core/server/http/base_path_service.ts
Lines 43 to 49 in bf04235
/** | |
* returns `basePath` value, specific for an incoming request. | |
*/ | |
public get = (request: KibanaRequest | LegacyRequest) => { | |
const requestScopePath = this.basePathCache.get(ensureRawRequest(request)) || ''; | |
return `${this.serverBasePath}${requestScopePath}`; | |
}; |
and prepend
only allow to preprend using the server's base path, not a request-scoped basePath:
kibana/src/core/server/http/base_path_service.ts
Lines 70 to 77 in bf04235
public prepend = (path: string): string => { | |
if (this.serverBasePath === '') return path; | |
return modifyUrl(path, (parts) => { | |
if (!parts.hostname && parts.pathname && parts.pathname.startsWith('/')) { | |
parts.pathname = `${this.serverBasePath}${parts.pathname}`; | |
} | |
}); | |
}; |
But maybe adding a new core API is better. I was surprised to be the first to have such need on the server-side TBH.
I can add something like prependRequestPath(path: string, request: KibanaRequest)
to the server-side BasePath
?
Summary
Related to #72331
Fix a bug causing the server-side GS results to use the server's basePath instead of the inbound request's when processing result urls.
Checklist