Repository navigation
Description
Bug report
import { Webhook } from 'https://esm.sh/[email protected]';
console.info('this is my deno function');
Deno.serve(async (req)=>{
console.log(`enter function ${req}`);
const payload = await req.text();
const base64_secret = Deno.env.get('AUTH_HOOK_TEST').replace('v1,whsec_', '');
const headers = Object.fromEntries(req.headers);
const wh = new Webhook(base64_secret);
try {
const { user_id, claims, authentication_method } = wh.verify(payload, headers);
if (claims.app_metadata && claims.app_metadata.role) {
claims['role'] = claims.app_metadata.role;
}
return new Response(JSON.stringify({
claims
}), {
status: 200,
headers: {
'Content-Type': 'application/json'
}
});
} catch (error) {
return new Response(JSON.stringify({
error: `Failed to process the request: ${error}, Headers: ${headers}, payload ${payload}`
}), {
status: 500,
headers: {
'Content-Type': 'application/json'
}
});
}
});
"POST | 401 | https://jhysiniamtglomqhpxmc.supabase.co/functions/v1/api-hook-second-try"
[
{
"deployment_id": "jhysiniamtglomqhpxmc_26b1c695-4151-4abd-bf56-4793796dce5c_7",
"execution_id": null,
"execution_time_ms": 799,
"function_id": "26b1c695-4151-4abd-bf56-4793796dce5c",
"project_ref": "jhysiniamtglomqhpxmc",
"request": [
{
"headers": [
{
"accept": null,
"accept_encoding": "gzip, br",
"connection": "Keep-Alive",
"content_length": "665",
"cookie": null,
"host": "jhysiniamtglomqhpxmc.supabase.co",
"user_agent": "Go-http-client/2.0",
"x_client_info": null
}
],
"host": "jhysiniamtglomqhpxmc.supabase.co",
"method": "POST",
"pathname": "/functions/v1/api-hook-second-try",
"port": null,
"protocol": "https:",
"sb": [],
"search": null,
"url": "https://jhysiniamtglomqhpxmc.supabase.co/functions/v1/api-hook-second-try"
}
],
"response": [
{
"headers": [
{
"content_length": "73",
"content_type": "application/json",
"date": "Tue, 11 Nov 2025 07:54:27 GMT",
"sb_request_id": "019a71e8-b05c-7e0a-9c89-844182d8a368",
"server": "cloudflare",
"vary": "Accept-Encoding",
"x_envoy_upstream_service_time": null,
"x_sb_compute_multiplier": null,
"x_sb_edge_region": "eu-west-1",
"x_sb_resource_multiplier": null,
"x_served_by": "supabase-edge-runtime"
}
],
"status_code": 401
}
],
"version": "7"
}
]
- I confirm this is a bug with Supabase, not with my own application.
- I confirm I have searched the Docs, GitHub Discussions, and Discord.
Describe the bug
I tried to use a edge function as auth hook to enrich my jwt token. But I get always rejected with 401.
I did the setup exactly as described in the docs and the code is also the example code.
the secret is generated from the AUTH HOOK Dashboard and I created a secret in the Edge Function secret settings.
When I try a simple example with a postgres function. I was able to enrich my token so I can tell that it is caused by the AUTH HOOK itself.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
you can copy the code from the report
Expected behavior
A clear and concise description of what you expected to happen.
Screenshots
If applicable, add screenshots to help explain your problem.
System information
- OS: [e.g. macOS, Windows]
- Browser (if applies) [e.g. chrome, safari]
- Version of supabase-js: [e.g. 6.0.2]
- Version of Node.js: [e.g. 10.10.0]
Additional context
Add any other context about the problem here.
Activity
JochnGst commentedon Nov 11, 2025
I have to apologize. When I switch "Verify JWT with legacy secret" off as recommended everything works fine.