How to get URL data to use with server.inject in the dev mode?

Kibana v6.2.4

In the dev mode, Kibana URL contains a random word which is changed after a restart, for example, poj word here


How to get the word in a custom plugin server-side code?

In my Kibana plugin, I use server.inject()

async function logData(attributes) {
  const resp = await server.inject({
    method: 'PUT',
    url: '/api/myplugin/alarm',
    headers: {
      'kbn-xsrf': 'reporting',
    payload: {

  ... do stuff

to query the plugin API route from the server code

    method: ['PUT'],
    path: '/api/myplugin/alarm/{id?}',
    config: {
      validate: {
        params: {
          id: Joi.string(),
        payload: {
          attributes: Joi.object().required(),
    handler: async function (req, reply) {
    ... do stuff

And it works when I run Kibana in the normal mode. But when I run it in the dev mode cd kibana && npm start, I get a raw response with 404 Not Found in the header:

{ raw:
   { res:
      Response {
        domain: [Object],
        socket: [Object],
        connection: [Object],
        _header: 'HTTP/1.1 404 Not Found\r\nkbn-name: kibana\r\nkbn-version: 6.2.4\r\ncontent-type: application/json; charset=utf-8\r\ncache-control: no-cache\r\ncontent-length: 38\r\nDate: Mon, 17 Sep 2018 16:32:02 GMT\r\nConnection: keep-alive\r\n\r\n',

I understand this is because I don't have the random word in the server.inject() url.

The related question on Stack Overflow:


The example in the question works! The problem was that in my real code I used a wrong path in the route.

Hi ,
Can you try this? Try passing --no-base-path in dev to eliminate the random base path.

hope this helps eliminating the issue u r seeing.


Glad u posted the update in your original post .


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.