Skip to content

Commit b4e7537

Browse files
committed
No, it's really in the headers
1 parent 9dd5c00 commit b4e7537

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

api/sockets/wsAuthorizer.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ interface WebSocketAuthorizerEvent {
44
type: string;
55
methodArn: string;
66
headers?: Record<string, string>;
7+
multiValueHeaders?: Record<string, string[]>;
78
identitySource?: string[];
89
}
910

@@ -15,11 +16,9 @@ const verifier = CognitoJwtVerifier.create({
1516

1617
export const wsAuthorizer = async (event: WebSocketAuthorizerEvent) => {
1718
console.log("Authorizer event:", JSON.stringify(event));
18-
const token = event.identitySource?.[0];
19-
// // API Gateway normalizes header keys to lowercase
20-
// const token =
21-
// event.headers?.["sec-websocket-protocol"] ||
22-
// event.headers?.["Sec-WebSocket-Protocol"];
19+
const token =
20+
event.headers?.["Sec-WebSocket-Protocol"] ||
21+
event.multiValueHeaders?.["Sec-WebSocket-Protocol"]?.[0];
2322

2423
if (!token) {
2524
console.error("Missing Sec-WebSocket-Protocol header");

0 commit comments

Comments
 (0)