Skip to content

Commit e52887f

Browse files
feat: overwrite host headers when custom domain name (#105)
1 parent 0f25752 commit e52887f

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

lib/stac-api/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
Duration,
99
aws_logs,
1010
} from "aws-cdk-lib";
11-
import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha";
11+
import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha";
1212
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1313
import { Construct } from "constructs";
1414
import { CustomLambdaFunctionProps } from "../utils";
@@ -54,7 +54,13 @@ export class PgStacApiLambda extends Construct {
5454
defaultDomainMapping: props.stacApiDomainName ? {
5555
domainName: props.stacApiDomainName
5656
} : undefined,
57-
defaultIntegration: new HttpLambdaIntegration("integration", this.stacApiLambdaFunction),
57+
defaultIntegration: new HttpLambdaIntegration(
58+
"integration",
59+
this.stacApiLambdaFunction,
60+
props.stacApiDomainName ? {
61+
parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.stacApiDomainName.name))
62+
} : undefined
63+
),
5864
});
5965

6066
this.url = stacApi.url!;

lib/tipg-api/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
CfnOutput,
99
Duration,
1010
} from "aws-cdk-lib";
11-
import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha";
11+
import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha";
1212
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1313
import { Construct } from "constructs";
1414
import { CustomLambdaFunctionProps } from "../utils";
@@ -52,7 +52,13 @@ import {
5252
defaultDomainMapping: props.tipgApiDomainName ? {
5353
domainName: props.tipgApiDomainName
5454
} : undefined,
55-
defaultIntegration: new HttpLambdaIntegration("integration", this.tiPgLambdaFunction),
55+
defaultIntegration: new HttpLambdaIntegration(
56+
"integration",
57+
this.tiPgLambdaFunction,
58+
props.tipgApiDomainName ? {
59+
parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.tipgApiDomainName.name))
60+
} : undefined
61+
),
5662
});
5763

5864
this.url = tipgApi.url!;

lib/titiler-pgstac-api/index.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
Duration,
1010
aws_logs
1111
} from "aws-cdk-lib";
12-
import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha";
12+
import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha";
1313
import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha";
1414
import { Construct } from "constructs";
1515
import { CustomLambdaFunctionProps } from "../utils";
@@ -78,7 +78,13 @@ import { CustomLambdaFunctionProps } from "../utils";
7878
defaultDomainMapping: props.titilerPgstacApiDomainName ? {
7979
domainName: props.titilerPgstacApiDomainName
8080
} : undefined,
81-
defaultIntegration: new HttpLambdaIntegration("integration", this.titilerPgstacLambdaFunction),
81+
defaultIntegration: new HttpLambdaIntegration(
82+
"integration",
83+
this.titilerPgstacLambdaFunction,
84+
props.titilerPgstacApiDomainName ? {
85+
parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.titilerPgstacApiDomainName.name))
86+
} : undefined
87+
),
8288
});
8389

8490
this.url = stacApi.url!;

0 commit comments

Comments
 (0)