You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suggestion to improve this in the SDKs by exposing the auth header tokens a little more cleanly.
If you've got your middleware in the same file as your handler, it can be a little messy with the imports as well since we have a naming conflict with jwt.
import { api, jwt } from "@nitric/sdk";
import { jwt as decoder } from "jsonwebtoken";
The text was updated successfully, but these errors were encountered:
Looks like you have to do a little parsing to get hold of the contents of the authentication token.
const authHeader = Array.isArray(ctx.req.headers["authorization"])
? ctx.req.headers["authorization"][0]
: ctx.req.headers["authorization"];
const accessToken: string | undefined = authHeader?.split(" ")[1];
const decoded = decoder.decode(accessToken);
const audience = decoded!["......"]; // claim
Suggestion to improve this in the SDKs by exposing the auth header tokens a little more cleanly.
If you've got your middleware in the same file as your handler, it can be a little messy with the imports as well since we have a naming conflict with jwt.
import { api, jwt } from "@nitric/sdk";
import { jwt as decoder } from "jsonwebtoken";
The text was updated successfully, but these errors were encountered: