Skip to content

Expose context on hono-party middleware #310

@vickyRathee

Description

@vickyRathee

How to access ctx.env in partyserverMiddleware. Isn't ctx exposed on the middleware?

app.use(
  '*',
  partyserverMiddleware({
    options: {
      onBeforeConnect(req, lobby) {
        const url = new URL(req.url);
        const token = url.searchParams.get('token');
       >>> access env variable        ctx.env.JWT_SECRET ?
       // validate token
       // set header
        req.headers.set('X-User-Id', 'account id');
      },
    },
  })
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions