Skip to content

Commit

Permalink
docs(cloudfront-origins): add instructions in readme to change the or…
Browse files Browse the repository at this point in the history
…igin path when using origins.RestApiOrigin
  • Loading branch information
oieduardorabelo committed Feb 10, 2023
1 parent d2bdbc7 commit 58e9396
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/@aws-cdk/aws-cloudfront-origins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ new cloudfront.Distribution(this, 'myDist', {
## From an API Gateway REST API

Origins can be created from an API Gateway REST API. It is recommended to use a
[regional API](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-endpoint-types.html) in this case.
[regional API](https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-endpoint-types.html) in this case. The origin path will automatically be set as the stage name.

```ts
declare const api: apigateway.RestApi;
Expand All @@ -131,4 +131,11 @@ new cloudfront.Distribution(this, 'Distribution', {
});
```

The origin path will automatically be set as the stage name.
If you want to use a different origin path, you can specify it in the `originPath` property.

```ts
declare const api: apigateway.RestApi;
new cloudfront.Distribution(this, 'Distribution', {
defaultBehavior: { origin: new origins.RestApiOrigin(api, { originPath: '/custom-origin-path' }) },
});
```

0 comments on commit 58e9396

Please sign in to comment.