Error: Missing Clerk Secret key
I'm using clerk with hono middleware to handle auth: https://clerk.com/changelog/2023-11-08
The code is really simple:
import { clerkMiddleware, getAuth } from "@hono/clerk-auth";
import { serve } from "@hono/node-server";
import { Hono } from "hono";
const app = new Hono();
app.use(clerkMiddleware());
app.get("/", (c) => {
try {
const auth = getAuth(c);
if (!auth?.userId) {
return c.json({
message: "You are not logged in.",
});
}
return c.json({
message: "You are logged in!",
userId: auth.userId,
});
} catch (err) {
return c.json({
message: JSON.stringify(err),
});
}
});
const port = 3000;
console.log(
Server is running on port ${port});
serve({
fetch: app.fetch,
port,
});
.env file
CLERK_SECRET_KEY=
CLERK_PUBLISHABLE_KEY=
DATABASE_URL=
I'm getting this error:
Server is running on port 3000
Error: Missing Clerk Secret key
at C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\@hono\clerk-auth\dist\index.cjs:42:13
at dispatch (C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\hono\dist\cjs\compose.js:51:23)
at C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\hono\dist\cjs\compose.js:28:12
at C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\hono\dist\cjs\hono-base.js:211:31
at Hono.dispatch (C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\hono\dist\cjs\hono-base.js:221:7)
at fetch (C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\hono\dist\cjs\hono-base.js:224:17)
at Server.<anonymous> (C:\Users\840 G5\Desktop\projects\pfe\web-service\node_modules\@hono\node-server\dist\index.js:430:13)
at Server.emit (node:events:518:28)
at Server.emit (node:domain:488:12)
at parserOnIncoming (node:_http_server:1151:12)
Use Clerk with Hono middleware
Hono is a great minimal web framework for building applications across any edge runtime and now with Hono's middleware and our community SDK, you can secure it with Clerk.
2 Replies