I have a Next.js + React app. I have an existing API defined in src/app/api/feature/route.ts. I want to use a command like curl -X POST http://localhost:3000/api/feature -d '{"key": "value"}' -H "Content-type: application/json" to test the endpoint manually from command line. In route.ts we get the Clerk JWT using:
const { isSignedIn } = await clerkClient.authenticateRequest(req, {
jwtKey: process.env.CLERK_JWT_KEY,
});
if (!isSignedIn) {
return Response.json({
"errorMessage": "Invalid JWT provided in Authorization header!"
}, {
status: 401
});
}
So when I run that POST command, I get the error message: {"errorMessage":"Invalid JWT provided in Authorization header!"}
So, looks like I need the JWT that Clerk generated when I logged into the app in the UI. How do I do that, if that's even the right approach or possible?