-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
HTML page rendering service #41964
Comments
Pinging @elastic/kibana-platform |
Server-side:In the new platform, we have one js bundle - There are a few blockers on the server-side. We should either migrate them to the New platform or bridge Legacy platform API for a while (available via Hapi server object):
Steps:
interface KibanaRenderParams {
strictCsp: boolean;
bootstrapScriptUrl: string;
...
}
interface RenderingServiceSetup {
renderKibanaPage(params: KibanaRenderParams): string;
const page = rendering.renderKibanaPage();
return response.ok(page);
Client-sideThe current implementation of
core.application.register({
id: 'security',
globalURL: ['/login', '/logout'],
async mount(context, params) {
// mount is called for `/app/security`, `/login` and `/logout`
return renderApp(context, params);
},
});
// or register as a separate app
core.application.register({
id: 'security-login',
globalURL: '/login',
async mount(context, params) {
// mount is called for `/login` only
return renderApp(context, params);
},
});
core.standalonePage.register({
url: '/login',
async mount(context, params) {
// mount is called for `/login` only
return renderApp(context, params);
},
});
core.chrome.addLink({ title, icon: ... })
core.application.register({ id, mount... }); |
Until the new API is ready we need to recommend a workaround.
|
I proposed something similar to the second option here: #49102 (comment) I think that's a practical way forward, but we should be careful about which options we expose in the NP API so we don't have too much churn from breaking it in the future. |
consider adding a rendering helper #54470 (comment) |
The current implementation has a couple of drawbacks:
return response.ok({
body: await context.core.rendering.render({ includeUserSettings: true }),
headers: { 'content-security-policy': csp.header },
}); We would like to improve the situation and avoid error-prone manual configuration. It seems that this logic is more appropriate for HttpResource service #44620
interface HttpResourceSetup {
registerStaticApp: ({ path: string }) => void
}
httpResource.registerStaticApp({ path: '/my-url'})
interface HttpResourceSetup {
registerApp: (RouteConfig<'get'>) => KibanaResponse
}
httpResource.registerApp({ path: '/my-url', validate: false }, async (context, request, response) => {
// response already pre-configured with necessary CSP, Content-Type, Cache-control headers
// plugins can override headers except for CSP header
return response.ok({
body: `<!DOCTYPE html> ...`
headers:
}); Are we okay with this proposal? |
I wonder if we couldn't improve the ergonomics of a regular app that needs a custom route (not prefixed with
This API seems to do very little. It feels like it should just be part of the res.html({ html: ``, headers: {} }); |
I thought about it, but I decided it wasn't enough for a few (maybe minor) reasons:
Why not for both prefixed and un-prefixed apps? As I understand, a user can land on any page. |
Let's move discussion to #50654 |
will be done in #50654 |
Rendering a view populates an HTML page with build artifacts and additional meta-data to bootstrap client-side core services and plugins.
Currently, Kibana supports 2 types of view rendering in ui_mixin
Also, there is an implicit concept of lightweight applications. Those applications do not have client code of the Kibana app but should have the same headers (CSP, CORS, etc.) as normal Kibana HTML page
HttpResource service (#44620) or another rendering service should provide API covering all 3 use-cases.
Known limitations
Concepts of
uiExports
andoptimizer
from Legacy platform don't exist in the New platform. Thus a Legacy platform code cannot be accessed, loaded and bootstrapped within the New Platform core.Blocked by #18843Related:
#41981
The text was updated successfully, but these errors were encountered: