# domain-web-redirect

> An AWS CDK construct that redirects all http/https requests for one domain to another.

Latest version **1.0.1** (published 2020-11-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install domain-web-redirect
pnpm add domain-web-redirect
yarn add domain-web-redirect
bun add domain-web-redirect
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2020-11-23 |
| First published | 2020-11-23 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 13.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | mpvosseller |
| Keywords | aws, cdk, construct, s3, cloudfront, domain, redirect, redirects |

## Links

- npm: https://www.npmjs.com/package/domain-web-redirect
- Repository: https://github.com/mpvosseller/domain-web-redirect
- npm.io page: https://npm.io/package/domain-web-redirect

## Dependencies (1)

- [cdk-cloudfront-invalidator](https://npm.io/package/cdk-cloudfront-invalidator.md) ^1.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-11-23
- 1.0.0 — 2020-11-23
- 0.1.0 — 2020-11-23

## README

# domain-web-redirect

An AWS CDK construct that redirects all http/https requests for one domain to another.

`DomainWebRedirect` is an [AWS CDK](https://aws.amazon.com/cdk) construct that redirects
web requests for one or more `source` domains to a `target` domain. This could be used
to redirect from the `www` domain (e.g. `www.example.com`) to the APEX / naked domain
(e.g. `example.com`) or vice versa.

In addition to the `source` and `target` domain names you must also provide:

- the `IHostedZone` of each `source` domain
- one `ICertificate` that is valid for all `source` domains

Note that this uses 301 permanent redirects which browsers cache without an expiration
date. This means that if you set this up and later modify the `target` domain you
should also configure the old `target` domain to redirect to the new `target` domain.

## Installation

```
npm install domain-web-redirect

# install any peer dependencies not already installed
npm install @aws-cdk/aws-certificatemanager @aws-cdk/aws-cloudfront @aws-cdk/aws-iam @aws-cdk/aws-lambda @aws-cdk/aws-route53 @aws-cdk/aws-route53-targets @aws-cdk/core
```

## Usage

```typescript
import * as acm from '@aws-cdk/aws-certificatemanager'
import * as route53 from '@aws-cdk/aws-route53'
import { DomainWebRedirect } from 'domain-web-redirect'

// redirect requests for http://source.example.com and https://source.example.com to https://target.example.com
new DomainWebRedirect(this, 'DomainWebRedirect', {
  sourceDomains: [
    {
      domainName: 'source.example.com',
      hostedZone: route53.HostedZone.fromLookup(this, `HostedZone`, {
        domainName: 'example.com',
      }),
    },
  ],
  certificate: acm.Certificate.fromCertificateArn(
    this,
    'Certificate',
    'arn:aws:acm:region:account:certificate/123456789012-1234-1234-1234-12345678'
  ),
  targetDomain: 'target.example.com',
})
```

---
_Source: https://npm.io/package/domain-web-redirect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
