Skip to content

Commit 799bd0d

Browse files
Merge pull request #1455 from exogee-technology/feature/configure-origins
Expose config option for allowed origins
2 parents 9d06116 + 3a5744b commit 799bd0d

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/packages/cdk/src/app/lambda.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
1-
import path from 'node:path';
21
import * as cdk from 'aws-cdk-lib';
2+
import { AccessLogFormat, LambdaRestApi, LogGroupLogDestination } from 'aws-cdk-lib/aws-apigateway';
3+
import { Certificate } from 'aws-cdk-lib/aws-certificatemanager';
34
import * as ec2 from 'aws-cdk-lib/aws-ec2';
45
import * as lambda from 'aws-cdk-lib/aws-lambda';
56
import { NodejsFunction } from 'aws-cdk-lib/aws-lambda-nodejs';
67
import { LogGroup } from 'aws-cdk-lib/aws-logs';
7-
import { AccessLogFormat, LambdaRestApi, LogGroupLogDestination } from 'aws-cdk-lib/aws-apigateway';
8-
import { Certificate } from 'aws-cdk-lib/aws-certificatemanager';
98
import { Construct } from 'constructs';
109

11-
import { GraphweaverAppConfig } from './types';
1210
import { DatabaseStack } from './database';
11+
import { GraphweaverAppConfig } from './types';
1312

1413
export class LambdaStack extends cdk.NestedStack {
1514
public readonly lambda: lambda.Function;
@@ -107,7 +106,7 @@ export class LambdaStack extends cdk.NestedStack {
107106
accessLogFormat: AccessLogFormat.jsonWithStandardFields(),
108107
},
109108
defaultCorsPreflightOptions: {
110-
allowOrigins: [`https://${config.adminUI.url}`],
109+
allowOrigins: config.lambda.allowedOrigins ?? [`https://${config.adminUI.url}`],
111110
allowMethods: ['GET', 'POST', 'OPTIONS'],
112111
allowHeaders: [
113112
'Content-Type',

src/packages/cdk/src/app/types.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ResponseCustomHeader } from 'aws-cdk-lib/aws-cloudfront';
2-
import { IVpc, SecurityGroup, InstanceType } from 'aws-cdk-lib/aws-ec2';
2+
import { InstanceType, IVpc, SecurityGroup } from 'aws-cdk-lib/aws-ec2';
33
import { Runtime } from 'aws-cdk-lib/aws-lambda';
44
import { PostgresEngineVersion } from 'aws-cdk-lib/aws-rds';
55

@@ -78,5 +78,7 @@ export type GraphweaverAppConfig = {
7878
handler?: string;
7979
// Pass the database secret ARN to the Lambda function
8080
databaseSecretFullArn?: string;
81+
// A list of CORS origins to allow. Defaults to the admin UI URL.
82+
allowedOrigins?: string[];
8183
};
8284
};

0 commit comments

Comments
 (0)