Skip to content

Commit

Permalink
Correctly lookup AWS region.
Browse files Browse the repository at this point in the history
  • Loading branch information
aduros committed Nov 29, 2023
1 parent bc9db52 commit 001ecfe
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions runtimes/web/webrtc-signal-server/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import { ApiGatewayManagementApiClient, PostToConnectionCommand } from "@aws-sdk

export const handler: APIGatewayProxyWebsocketHandlerV2 = async ({ body, requestContext }) => {
async function sendToPeer (source: string, target: string, message: object) {
const region = process.env.AWS_REGION ?? process.env.AWS_DEFAULT_REGION ?? "us-east-1";
const client = new ApiGatewayManagementApiClient({
apiVersion: "2018-11-29",
endpoint: process.env.IS_OFFLINE
? "http://localhost:3001"
: requestContext.domainName.endsWith(".wasm4.org")
? `https://${requestContext.apiId}.execute-api.us-east-1.amazonaws.com/${requestContext.stage}`
: `https://${requestContext.domainName}/${requestContext.stage}`,
: `https://${requestContext.apiId}.execute-api.${region}.amazonaws.com/${requestContext.stage}`,
credentials: process.env.IS_OFFLINE
? { accessKeyId: "offline", secretAccessKey: "offline" }
: undefined,
Expand Down

0 comments on commit 001ecfe

Please sign in to comment.