@nevermined-io/payments
    Preparing search index...

    Function createRequireAuthMiddleware

    • Create a middleware that requires a Bearer token in the Authorization header. Returns HTTP 401 if the token is missing or malformed.

      This is a lightweight check that only verifies presence of a token. Full validation (is the token valid? does the user have access?) is handled by withPaywall() when a tool is actually called.

      Returns (req: Request, res: Response, next: NextFunction) => void

      Express middleware for token requirement

      const requireAuth = createRequireAuthMiddleware()

      // Protect MCP endpoints
      app.post('/mcp', requireAuth, mcpHandler)
      app.get('/mcp', requireAuth, sseHandler)