Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions examples/custom-jwt-validation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,26 @@

This function exemplifies how to use a custom JWT validation.

Since Supabase legacy JWT Secret will be deprecated, users that would like to verify JWT or integrate with a custom provider should implement it manually.
> see [Upcoming changes to Supabase API Keys #29260](https://github.com/orgs/supabase/discussions/29260)
Since Supabase legacy JWT Secret will be deprecated, users that would like to
verify JWT or integrate with a custom provider should implement it manually.

> see
> [Upcoming changes to Supabase API Keys #29260](https://github.com/orgs/supabase/discussions/29260)

To simplify this task, Supabase provides a collection of JWT validation examples
that can be found at [`_shared/jwt/`](https://github.com/supabase/edge-runtime/blob/main/examples/_shared/jwt) folder.
that can be found at
[`_shared/jwt/`](https://github.com/supabase/edge-runtime/blob/main/examples/_shared/jwt)
folder.

## Setup

1. Copy/download the JWT template, then import and use it inside your edge function.
1. Copy/download the JWT template, then import and use it inside your edge
function.

```bash
wget https://raw.githubusercontent.com/supabase/edge-runtime/refs/heads/main/examples/_shared/jwt/<template>.ts
```

2. Add any required Environment-Variable to a `.env` file, see inside of the
respective `_shared/jwt/template.ts` file to find which variables is required.
respective `_shared/jwt/template.ts` file to find which variables is
required.
13 changes: 11 additions & 2 deletions ext/runtime/js/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,17 @@ function serveHttp(conn) {
streamRid: nextRequest.streamRid,
};

return nextRequest;
return {
...nextRequest,
respondWith: async function (resp) {
try {
return await nextRequest.respondWith(resp);
} catch (error) {
console.error(error);
throw error;
}
},
};
};

httpConn.close = () => {
Expand Down Expand Up @@ -271,7 +281,6 @@ async function respond(requestEvent, httpConn, options, snapshot) {
}),
);
} catch (error) {
console.error(error);
closeHttpConn(httpConn);
}
});
Expand Down
2 changes: 1 addition & 1 deletion scripts/format.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env -S deno run --allow-all
#!/usr/bin/env -S deno run --allow-write --allow-read --allow-run --allow-net
// Copyright 2018-2025 the Deno authors. MIT license.

import { dirname, fromFileUrl, join } from "jsr:@std/path";
Expand Down
Loading