Skip to content
This repository was archived by the owner on Jan 28, 2025. It is now read-only.

Commit c97808f

Browse files
authored
feat(nextjs-component): allow other path patterns in cloudfront inputs (#1631)
1 parent 70fd736 commit c97808f

File tree

2 files changed

+2
-39
lines changed

2 files changed

+2
-39
lines changed

packages/serverless-components/nextjs-component/__tests__/custom-inputs.test.ts

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -940,41 +940,6 @@ describe("Custom inputs", () => {
940940
});
941941
});
942942

943-
describe.each`
944-
cloudFrontInput | expectedErrorMessage
945-
${{ "some-invalid-page-route": { ttl: 100 } }} | ${'Could not find next.js pages for "some-invalid-page-route"'}
946-
`(
947-
"Invalid cloudfront inputs",
948-
({ cloudFrontInput, expectedErrorMessage }) => {
949-
const fixturePath = path.join(__dirname, "./fixtures/generic-fixture");
950-
let tmpCwd: string;
951-
952-
beforeEach(() => {
953-
tmpCwd = process.cwd();
954-
process.chdir(fixturePath);
955-
956-
mockServerlessComponentDependencies({ expectedDomain: undefined });
957-
});
958-
959-
afterEach(() => {
960-
process.chdir(tmpCwd);
961-
return cleanupFixtureDirectory(fixturePath);
962-
});
963-
964-
it("throws the correct error", async () => {
965-
expect.assertions(1);
966-
967-
try {
968-
await createNextComponent().default({
969-
cloudfront: cloudFrontInput
970-
});
971-
} catch (err) {
972-
expect(err.message).toContain(expectedErrorMessage);
973-
}
974-
});
975-
}
976-
);
977-
978943
describe.each`
979944
cloudFrontInput | pathName
980945
${{ api: { minTTL: 100, maxTTL: 100, defaultTTL: 100 } }} | ${"api"}

packages/serverless-components/nextjs-component/src/component.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,8 @@ class NextjsComponent extends Component {
163163
}
164164

165165
if (stillToMatch.size > 0) {
166-
throw Error(
167-
`CloudFront input failed validation. Could not find next.js pages for "${[
168-
...stillToMatch
169-
]}"`
166+
this.context.debug(
167+
"There are other CloudFront path inputs that are not next.js pages, which will be added as custom behaviors."
170168
);
171169
}
172170
}

0 commit comments

Comments
 (0)