Skip to content

Commit

Permalink
feat: overwrite host headers when custom domain name (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentsarago committed May 14, 2024
1 parent 0f25752 commit e52887f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
10 changes: 8 additions & 2 deletions lib/stac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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!;
Expand Down
10 changes: 8 additions & 2 deletions lib/tipg-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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!;
Expand Down
10 changes: 8 additions & 2 deletions lib/titiler-pgstac-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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!;
Expand Down

0 comments on commit e52887f

Please sign in to comment.