Skip to content
Merged
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
15 changes: 12 additions & 3 deletions packages/deploy-trigger/src/deploy-trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,16 @@ async function deployTrigger({
* | └── prerendered-site
* └── config.json
*
* And uploads it to the bucket in the following way
* And uploads it to the bucket in the following way:
*
* <deployment-id>/
* ├── lambdas/
* | ├── lambda1.zip
* | └── lambda2.zip
* ├── static/
* | ├── _next/...
* | └── prerendered-site
* └── manifest.json (contains the inventory of the `<deployment-id>/` path)
*/
for await (const e of zip) {
const entry = e as unzipper.Entry;
Expand All @@ -106,7 +115,7 @@ async function deployTrigger({
continue;
} else if (filePath.startsWith('lambdas')) {
contentType = 'application/zip';
targetKey = `${deploymentId}/_tf_next/${filePath}`;
targetKey = `${deploymentId}/lambdas/${filePath}`;

lambdaUploads.push(
s3
Expand All @@ -120,7 +129,7 @@ async function deployTrigger({
);
} else {
const filePathWithoutPrefix = filePath.substring('static/'.length);
targetKey = `${deploymentId}/${filePathWithoutPrefix}`;
targetKey = `${deploymentId}/static/${filePathWithoutPrefix}`;

// Get ContentType
// Static pre-rendered pages have no file extension,
Expand Down
8 changes: 4 additions & 4 deletions packages/deploy-trigger/test/deploy-trigger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe('deploy-trigger', () => {
expect(Contents).toEqual(
expect.arrayContaining([
expect.objectContaining({
Key: `${deploymentId}/${fileKey}`,
Key: `${deploymentId}/static/${fileKey}`,
}),
])
);
Expand All @@ -112,7 +112,7 @@ describe('deploy-trigger', () => {
const localeStaticRouteObject = await s3
.getObject({
Bucket: targetBucket.bucketName,
Key: `${deploymentId}/${localeStaticRouteKey}`,
Key: `${deploymentId}/static/${localeStaticRouteKey}`,
})
.promise();

Expand All @@ -127,7 +127,7 @@ describe('deploy-trigger', () => {
const staticRouteObject = await s3
.getObject({
Bucket: targetBucket.bucketName,
Key: `${deploymentId}/${staticRouteKey}`,
Key: `${deploymentId}/static/${staticRouteKey}`,
})
.promise();

Expand All @@ -139,7 +139,7 @@ describe('deploy-trigger', () => {
const staticAssetObject = await s3
.getObject({
Bucket: targetBucket.bucketName,
Key: `${deploymentId}/${staticAssetKey}`,
Key: `${deploymentId}/static/${staticAssetKey}`,
})
.promise();
expect(staticAssetObject.ContentType).toBe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ async function deploymentFileExists({
const result = await s3Client
.headObject({
Bucket: s3BucketId,
Key: deploymentId + '/' + decodedKey,
Key: deploymentId + '/static/' + decodedKey,
})
.promise();

Expand Down
2 changes: 1 addition & 1 deletion packages/proxy/src/util/custom-origin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function serveRequestFromS3Origin(
});

if (typeof uri === 'string') {
request.uri = `/${deploymentId}${uri}`;
request.uri = `/${deploymentId}/static${uri}`;
}

// Querystring is not supported by S3 origin
Expand Down
6 changes: 3 additions & 3 deletions packages/proxy/test/handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ describe('[proxy] Handler', () => {
})
);
// deploymentId + path
expect(result.uri).toBe('/abc/en');
expect(result.uri).toBe('/abc/static/en');
});

test('Correctly request /index object from S3 when requesting /', async () => {
Expand Down Expand Up @@ -372,7 +372,7 @@ describe('[proxy] Handler', () => {
path: '',
})
);
expect(result.uri).toBe('/abc/index');
expect(result.uri).toBe('/abc/static/index');
});

test('Add x-forwarded-host header to API-Gateway requests', async () => {
Expand Down Expand Up @@ -636,7 +636,7 @@ describe('[proxy] Handler', () => {
path: '',
})
);
expect(result.uri).toBe('/abc/users/[user_id]');
expect(result.uri).toBe('/abc/static/users/[user_id]');
});

test('Redirects with querystring', async () => {
Expand Down