diff --git a/lib/stac-api/index.ts b/lib/stac-api/index.ts index 9fe86d8..91e9864 100644 --- a/lib/stac-api/index.ts +++ b/lib/stac-api/index.ts @@ -8,7 +8,7 @@ import { Duration, aws_logs, } from "aws-cdk-lib"; -import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha"; +import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha"; import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha"; import { Construct } from "constructs"; import { CustomLambdaFunctionProps } from "../utils"; @@ -54,7 +54,13 @@ export class PgStacApiLambda extends Construct { defaultDomainMapping: props.stacApiDomainName ? { domainName: props.stacApiDomainName } : undefined, - defaultIntegration: new HttpLambdaIntegration("integration", this.stacApiLambdaFunction), + defaultIntegration: new HttpLambdaIntegration( + "integration", + this.stacApiLambdaFunction, + props.stacApiDomainName ? { + parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.stacApiDomainName.name)) + } : undefined + ), }); this.url = stacApi.url!; diff --git a/lib/tipg-api/index.ts b/lib/tipg-api/index.ts index 37f8b5c..d99c8bc 100644 --- a/lib/tipg-api/index.ts +++ b/lib/tipg-api/index.ts @@ -8,7 +8,7 @@ import { CfnOutput, Duration, } from "aws-cdk-lib"; - import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha"; + import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha"; import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha"; import { Construct } from "constructs"; import { CustomLambdaFunctionProps } from "../utils"; @@ -52,7 +52,13 @@ import { defaultDomainMapping: props.tipgApiDomainName ? { domainName: props.tipgApiDomainName } : undefined, - defaultIntegration: new HttpLambdaIntegration("integration", this.tiPgLambdaFunction), + defaultIntegration: new HttpLambdaIntegration( + "integration", + this.tiPgLambdaFunction, + props.tipgApiDomainName ? { + parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.tipgApiDomainName.name)) + } : undefined + ), }); this.url = tipgApi.url!; diff --git a/lib/titiler-pgstac-api/index.ts b/lib/titiler-pgstac-api/index.ts index 61708e5..c6413ce 100644 --- a/lib/titiler-pgstac-api/index.ts +++ b/lib/titiler-pgstac-api/index.ts @@ -9,7 +9,7 @@ import { Duration, aws_logs } from "aws-cdk-lib"; - import { IDomainName, HttpApi } from "@aws-cdk/aws-apigatewayv2-alpha"; + import { IDomainName, HttpApi, ParameterMapping, MappingValue} from "@aws-cdk/aws-apigatewayv2-alpha"; import { HttpLambdaIntegration } from "@aws-cdk/aws-apigatewayv2-integrations-alpha"; import { Construct } from "constructs"; import { CustomLambdaFunctionProps } from "../utils"; @@ -78,7 +78,13 @@ import { CustomLambdaFunctionProps } from "../utils"; defaultDomainMapping: props.titilerPgstacApiDomainName ? { domainName: props.titilerPgstacApiDomainName } : undefined, - defaultIntegration: new HttpLambdaIntegration("integration", this.titilerPgstacLambdaFunction), + defaultIntegration: new HttpLambdaIntegration( + "integration", + this.titilerPgstacLambdaFunction, + props.titilerPgstacApiDomainName ? { + parameterMapping: new ParameterMapping().overwriteHeader('host', MappingValue.custom(props.titilerPgstacApiDomainName.name)) + } : undefined + ), }); this.url = stacApi.url!;