Handling requests with Node.js and Express
Node.js and Connect/Express Middleware
ClerkExpressWithAuth is a lax middleware that returns an empty auth object when an unauthenticated request is made.
ClerkExpressRequireAuth is a strict middleware that raises an error when an unauthenticated request is made.
Express Error Handlers
Express comes with a default error handler for errors encountered in the middleware chain.
Developers can also implement their own custom error handlers as detailed in the Express error handling guide. An example error handler can be found above.
If you are using the strict middleware variant, the
err pass to your error handler will contain enough context for you to respond as you deem fit.
Validate that the
For more information refer to Manual JWT Verification.
Clerk's JWT session token can be verified in a networkless manner using the JWT verification key.
By default, Clerk will use our well-known JWKs endpoint to fetch and cache the key for any subsequent token verification. If you use the
For more information refer to Networkless Token Verification.
|onError||(error: ClerkAPIResponseError) => unknown|
This function can act as a custom error handler tailored to the needs of your application.