* Disable even-better monitoring * Upgrade to Hapi v15 * Upgrade to Hapi v16 * Handle optional req params correctly * Update http and kbnServer * Get mocha tests passing * Convert `reply` usages [wip] * Fix Joi and Plugin incompatibilities * Get server up and running * Get basic logging working * Fix optimizer * Fix recent route handlers * Various fixes * Fix recent routes * Upgrade wreck for async/await * Fix mocha tests * Fix joi issues * Fix xpack jest tests * Fix recent routes * Fix tests * Fix index setup * Decouple monitoring stats collection from good plugin * Update reload logging test to work * Reimplement logging with updated good plugin * Fix unit tests * Fix getConnections back * Make LegacyLoggingServer compatible with Hapi v17 * Update joi types * Fix x-pack unit tests * Remove stray debugger * Remove hapi-compat * Fix API integrations * Upgrade boom * Fix security plugin * Misc fixes * bump * Fix licensePreRoutingFactory * Fix failing integration tests * Remove unnecessary test change * Remove hapi-latest package * fx * Various cleanup * Fix race condition in oppsy events * Use elastic/good fork * Fix boom.wrap and hapi-latest changes * Simplify LegacyLoggingServer updates * package.json cleanup + test fix * yarn.lock cleanup * Change good tag * Fixes * Change return err -> throw err in routes * Fix await returns * Fix new load_data test * Make cookie security flags consistent * tmp doc * Fix types * Fix tests * Upgrade canvas plugin * Move good package to published @elastic/good one * Fix SO test * Fix logging reloading * Update APM apis * Fix error logging * Fix logging test * Convert spaces plugin * Add validation error shim * Remove 7.0 release notes * Await renderApp * Fix ccr routes * Prevent header popovers from scrolling with page content (#23850) * Fix spaces test * new yarn.lock-s * Fix spaces tests * Remove h2o2-latest * Fix @types/hapi * Upgrade InfraOps plugin * Fix package.json * Add back isSameSite: false * Upgrade beats_management plugin * Update snapshot * Fix InfraOps * Upgrade kql_telemetry * Merge upstream/master * Upgrade apm and ml * Put snapshot test back * Fx beats * Upgrade rollups * Update boom usages in new plugins
87 lines
2.4 KiB
Text
87 lines
2.4 KiB
Text
[[development-basepath]]
|
|
=== Considerations for basePath
|
|
|
|
All communication from the Kibana UI to the server needs to respect the
|
|
`server.basePath`. Here are the "blessed" strategies for dealing with this
|
|
based on the context:
|
|
|
|
[float]
|
|
==== `<img>` and `<a>` elements
|
|
|
|
Write the `src` or `href` urls as you would without the base path, but then
|
|
replace `src` or `href` with `kbn-src` or `kbn-href`.
|
|
|
|
["source","shell"]
|
|
-----------
|
|
<img kbn-src="plugins/kibana/images/logo.png">
|
|
-----------
|
|
|
|
[float]
|
|
==== Getting a static asset url
|
|
|
|
Use webpack to import the asset into the build. This will give you a URL in
|
|
JavaScript and gives webpack a chance to perform optimizations and
|
|
cache-busting.
|
|
|
|
["source","shell"]
|
|
-----------
|
|
// in plugin/public/main.js
|
|
import uiChrome from 'ui/chrome';
|
|
import logoUrl from 'plugins/facechimp/assets/banner.png';
|
|
|
|
uiChrome.setBrand({
|
|
logo: `url(${logoUrl}) center no-repeat`
|
|
});
|
|
-----------
|
|
|
|
[float]
|
|
==== API requests from the front-end
|
|
|
|
Use `chrome.addBasePath()` to append the basePath to the front of the url.
|
|
|
|
["source","shell"]
|
|
-----------
|
|
import chrome from 'ui/chrome';
|
|
$http.get(chrome.addBasePath('/api/plugin/things'));
|
|
-----------
|
|
|
|
[float]
|
|
==== Server side
|
|
|
|
Append `request.getBasePath()` to any absolute URL path.
|
|
|
|
["source","shell"]
|
|
-----------
|
|
const basePath = server.config().get('server.basePath');
|
|
server.route({
|
|
path: '/redirect',
|
|
handler(request, h) {
|
|
return h.redirect(`${request.getBasePath()}/otherLocation`);
|
|
}
|
|
});
|
|
-----------
|
|
|
|
[float]
|
|
==== BasePathProxy in dev mode
|
|
|
|
The Kibana dev server automatically runs behind a proxy with a random
|
|
`server.basePath`. This way developers will be constantly verifying that their
|
|
code works with basePath, while they write it.
|
|
|
|
To accomplish this the `serve` task does a few things:
|
|
|
|
1. change the port for the server to the `dev.basePathProxyTarget` setting (default `5603`)
|
|
2. start a `BasePathProxy` at `server.port`
|
|
- picks a random 3-letter value for `randomBasePath`
|
|
- redirects from `/` to `/{randomBasePath}`
|
|
- redirects from `/{any}/app/{appName}` to `/{randomBasePath}/app/{appName}` so that refreshes should work
|
|
- proxies all requests starting with `/{randomBasePath}/` to the Kibana server
|
|
|
|
This proxy can sometimes have unintended side effects in development, so when
|
|
needed you can opt out by passing the `--no-base-path` flag to the `serve` task
|
|
or `yarn start`.
|
|
|
|
["source","shell"]
|
|
-----------
|
|
yarn start --no-base-path
|
|
-----------
|