Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    thanks @ggallovalle! I was looking actually for a link to join the slack - for that direct link you need to already be on the slack for it to work, and the joining link on the website is expired
    Nav Saini
    Hi all! How do I introduce same-site: None to my hapi 15.x app?
    (SameSite: None) cookie
    Hi Friends, In hapi 19 does anyone knows how to pass parameter "config" in the route
    We upgraded from hapi-15 to hapi-19 recently . As part of upgrade, hapi-swagger got updated from 7.8.1 to 13.0.2, now we are seeing hapi-swagger-UI is completely removed with new version. Can anyone suggest on how to go with this.
    "<script src='{{hapiSwagger.swaggerUIPath}}lib/jquery-1.8.0.min.js' type='text/javascript'></script>" This is giving 404 in hapi-swagger 13.x which was working perfectly fine in hapi-swagger 7.x
    Daniel Ji
    for cached server methods (aka catbox caching) has anyone tried to use the pendingGenerateTimeout property? No matter what value I set or not defining it, I can't seem to get concurrent access to a cache item working. It always queues it up and the same object is returned. Here's the sample code. I try to access /route1 and then wait a few seconds then access /route2, but they both return the same exact item. I would expect that since there is no cached item initially, that the calls to /route1 and /route2 should return different objects?
      function sleep(ms) {
        return new Promise((resolve) => {
          setTimeout(resolve, ms);
      const querySchemaMetadata = async () => {
        console.log(`regenerating cache ${(new Date()).toLocaleTimeString()}`);
        await sleep(9000);
        return Promise.resolve([{id: `${(new Date()).getMilliseconds()}`}]);
      server.method('querySchemaMetadata', querySchemaMetadata, {
        cache: {
          expiresIn: 60 * 60 * 1000,  // 1hr
           * provides a 15 second timeout querySchemaMetadata to return. Otherwise, returns a timeout error
          generateTimeout: false,
          //generateTimeout: 15 * 1000,
           * returns a wrapped object of the value that includes additional stats metadata
          getDecoratedValue: true,
           * allow multiple simultaneous access requests to this cache item to be queued for up to a duration of
           * 10 seconds before a separate access request is allowed.
          pendingGenerateTimeout: 2000,
        path: '/route1',
        method: 'GET',
        handler: async function (request, h) {
          await server.methods.querySchemaMetadata()
        path: '/route2',
        method: 'GET',
        handler: async function (request, h) {
          await server.methods.querySchemaMetadata();
    Ario K
    I'm trying to pass a JSON string in a get request
    when recieve, do a JSON.parse
    However, I cannot access the properties inside after JSON.parse
    via a Joi.string().optional() validation
    is there anything else needed to make a GET from the browser into hapi besides cors: true ?
    what i'm doing is:
    const server = Hapi.server({
      port: 9000,
      host: 'localhost',
      routes: {
        cors: true
      method: 'GET',
      path: '/',
      handler: (request, h) => {
        return 'Hello World!';
    and I can see the response body with curl or httpie, but from browser (tested with svelte and react apps) just got the following:
    Response {type: "cors", url: "http://localhost:9000/", redirected: false, status: 200, ok: true, …}
    body: (...)
    bodyUsed: false
    headers: Headers {}
    ok: true
    redirected: false
    status: 200
    statusText: "OK"
    type: "cors"
    url: "http://localhost:9000/"
    __proto__: Response
    without any response body... anyway
    Matthew Adams
    How do I match multiple parameters in a route, like /providers/{providerId}/fulfillers/{fulfillerId}/customers/{customerId}? https://hapi.dev/api/?v=20.0.3#path-parameters says hapi can only match one. Do I really have to use /providers/{things*} then do something like things.split('/')? Seems like a burden.
    devin ivy
    hello, member of the hapi technical steering committee here :wave: just wanted to share with those here that there is an official hapi slack. please join us, it's pretty lively over there :) https://join.slack.com/t/hapihour/shared_invite/zt-g5ortpsk-ErlnRA2rUcPIWES21oXBOg
    Megha Modi
    Screen Shot 2021-02-03 at 1.17.10 PM.png
    Hi, I am unable to get the results on HTML page from the SQL query I am using. I am not sure what I am doing wrong in this piece of code.
    Anyone knows how to log responseBody in hapi-pino. Google is telling to use serializers but i am not able to find right example on how to use serializer and log responseBody
    Is it possible to set more than one cookie in hapi-auth-cookie using
    request.cookieAuth.set() ??
    Roy Keene
    cookieAuth.set() sets the data within the cookie, usually to some kind of object. The cookie is encrypted and sent to the client.
    Someone can help me ? I have a payload stream, but i cant take the data of this payload
    Someone know how can i do this ?
    Cem Basaranoglu
    pals, I have an awkward error. I'm working on a legacy project and I got this error most of the time. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
    TypeError: msg.socket.cork is not a function what do u think? node version: 14.16 hapi version: 17.8.1
    Ario K
    anyone have any idea what Joi validation I can use to accept any type of json string object?
    I upgrade Joi and now Joi.object().optional() doesn't work
    Is there any way to rewrite the request headers in the lifecycle hook pre or ext ?
    application/xml fails if parse is true (default) for route
    Roy Keene
    I'm trying to use Lab to do some testing. Defining the tests requires an async function to run, which will return the list of things to test. But it's not clear how to make that work with Lab.
    Juan Gauna
    Hi there. Does anyone know how to use Glue with server.methods?
    Is there any gist or documentation on how to implement server-sent events(SSE) on the Hapi side?

    since I could set one cookie using (request.cookieAuth.set(data1)), setting one more data makes it more than 4k.

    I wanted to set 1 more cookie so , I did
    return reply.redirect(nextPath).state('data2', data2);
    but for some users , its not being set , could someone help me with this pls.