Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bestickley updates #2

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions examples/multiple-sites/src/stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,16 @@ export class MultipleSitesStack extends Stack {
},
})

const app1 = new Nextjs(this, 'app-router', {
new Nextjs(this, 'app-router', {
nextjsPath: '../../open-next/examples/app-router',
basePath: '/app-router',
defaults: {
distribution: {
cdk: { distribution }
}
}
distribution,
});

const app2 = new Nextjs(this, 'pages-router', {
new Nextjs(this, 'pages-router', {
nextjsPath: '../../open-next/examples/pages-router',
basePath: '/pages-router',
defaults: {
distribution: {
cdk: { distribution }
}
}
distribution,
});

new CfnOutput(this, "CloudFrontDistributionDomain", {
Expand Down
10 changes: 10 additions & 0 deletions src/Nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ export class Nextjs extends Construct {
constructor(scope: Construct, id: string, protected props: NextjsProps) {
super(scope, id);

this.validateProps(props);

// build nextjs app
this.nextBuild = new NextjsBuild(this, id, { ...props, tempBuildDir: this.tempBuildDir });

Expand Down Expand Up @@ -196,4 +198,12 @@ export class Nextjs extends Construct {
public get bucket(): s3.IBucket {
return this.staticAssets.bucket;
}

private validateProps(props: NextjsProps) {
if (props.distribution && props.defaults?.distribution) {
throw new Error(
'distribution and defaults.distribution were passed as props to Nextjs. defaults.distribution will have no affect. Please removed.'
);
}
}
}