Skip to content
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

Expose serverBasePath on client-side #57583

Closed
joshdover opened this issue Feb 13, 2020 · 4 comments · Fixed by #58070
Closed

Expose serverBasePath on client-side #57583

joshdover opened this issue Feb 13, 2020 · 4 comments · Fixed by #58070
Assignees
Labels
blocker Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc

Comments

@joshdover
Copy link
Contributor

Similar to #45991, Spaces needs access to the serverBasePath on the client-side. We should add this to the core.http.basePath interface in the browser.

@joshdover joshdover added blocker Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc Feature:New Platform labels Feb 13, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-platform (Team:Platform)

@pgayvallet
Copy link
Contributor

What is the difference with http.basePath.get() ? Aren't client and server basePath the same?

@legrego
Copy link
Member

legrego commented Feb 14, 2020

As far as I can tell, http.basePath.get() on the client-side returns the space-aware base path. So if a user is currently in the marketing space, and the server base path is /foo, then http.basePath.get() returns /foo/s/marketing, instead of /foo.

I imagine we'll want to expose a dedicated serverBasePath property via http.basePath.serverBasePath, in order to be consistent with the server basePath service.

Having access to serverBasePath is certainly a niche requirement. A vast majority of applications won't need this, and should instead use the space-aware base path

@pgayvallet
Copy link
Contributor

You are right.

Adding that to the injected metadata should be trivial.

(notes for later:)

Server

const basePath = http.basePath.get(request);

public get = (request: KibanaRequest | LegacyRequest) => {
const requestScopePath = this.basePathCache.get(ensureRawRequest(request)) || '';
return `${this.serverBasePath}${requestScopePath}`;
};

Client

public setup(): InjectedMetadataSetup {
return {
getBasePath: () => {
return this.state.basePath;
},

const basePath = new BasePath(injectedMetadata.getBasePath());

export class BasePath {
constructor(private readonly basePath: string = '') {}
public get = () => {
return this.basePath;
};

@joshdover joshdover added this to Prioritized Backlog in kibana-core [DEPRECATED] Feb 18, 2020
@joshdover joshdover self-assigned this Feb 18, 2020
kibana-core [DEPRECATED] automation moved this from Prioritized Backlog to Done (7.7) Feb 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Feature:New Platform Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc
Projects
Development

Successfully merging a pull request may close this issue.

4 participants