Skip to content

Commit

Permalink
presigned url code uploaded
Browse files Browse the repository at this point in the history
  • Loading branch information
dubwub committed Jan 23, 2025
1 parent c6735bf commit 794197b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
21 changes: 11 additions & 10 deletions packages/fern-docs/bundle/src/server/loadDocsDefinitionFromS3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ export async function loadDocsDefinitionFromS3({
try {
const cleanDomain = domain.replace(/^https?:\/\//, "");
const dbDocsDefUrl = `${docsDefinitionUrl}/${cleanDomain}.json`;
console.log("dbDocsDefUrl", dbDocsDefUrl);

const response = await fetch(
getSignedUrl({
url: dbDocsDefUrl,
privateKey: process.env.CLOUDFRONT_DOCS_DEFINITION_PRIVATE_KEY || "",
keyPairId: process.env.CLOUDFRONT_DOCS_DEFINITION_KEY_PAIR_ID || "",
dateLessThan: new Date(
Date.now() + 1000 * 60 * 60 * 24 * 30
).toString(),
})
);
const signedUrl = getSignedUrl({
url: dbDocsDefUrl,
privateKey: process.env.CLOUDFRONT_PRIVATE_KEY || "",
keyPairId: process.env.CLOUDFRONT_KEY_GROUP_ID || "",
dateLessThan: new Date(Date.now() + 1000 * 60 * 60 * 24 * 30).toString(),
});
console.log("signedUrl", signedUrl);
const response = await fetch(dbDocsDefUrl);
console.log("response", response.ok);
console.log("response.status", response.status);
if (response.ok) {
const json = await response.json();
return json as FdrAPI.docs.v2.read.LoadDocsForUrlResponse;
Expand Down
5 changes: 1 addition & 4 deletions packages/fern-docs/bundle/turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
"globalEnv": ["FERN_ENVIRONMENT", "APPLICATION_ENVIRONMENT"],
"tasks": {
"build": {
"env": [
"CLOUDFRONT_DOCS_DEFINITION_PRIVATE_KEY",
"CLOUDFRONT_DOCS_DEFINITION_KEY_PAIR_ID"
]
"env": ["CLOUDFRONT_PRIVATE_KEY", "CLOUDFRONT_KEY_GROUP_ID"]
},
"docs:build": {
"outputs": [".next/**", "!.next/cache/**"],
Expand Down
2 changes: 1 addition & 1 deletion servers/fdr-deploy/scripts/fdr-deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ export class FdrDeployStack extends Stack {
origin: new origins.S3Origin(dbDocsDefinitionBucket),
viewerProtocolPolicy:
cloudfront.ViewerProtocolPolicy.REDIRECT_TO_HTTPS,
cachePolicy: cloudfront.CachePolicy.CACHING_OPTIMIZED,
cachePolicy: cloudfront.CachePolicy.CACHING_DISABLED,
trustedKeyGroups: [dbDocsKeyGroup],
},
domainNames: [dbDocsDefinitionDomainName],
Expand Down

0 comments on commit 794197b

Please sign in to comment.