fix : reload pages 404 error
This commit is contained in:
@@ -13,18 +13,27 @@ import {
|
||||
Source,
|
||||
} from "aws-cdk-lib/aws-s3-deployment";
|
||||
import path from "path";
|
||||
import { renameSync } from "fs";
|
||||
import { ARecord, HostedZone, RecordTarget } from "aws-cdk-lib/aws-route53";
|
||||
import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";
|
||||
import { DnsValidatedCertificate } from "aws-cdk-lib/aws-certificatemanager";
|
||||
|
||||
interface AppStackProps extends cdk.StackProps {
|
||||
domainName: string;
|
||||
pagePaths: string[];
|
||||
}
|
||||
|
||||
export class AppStack extends cdk.Stack {
|
||||
constructor(scope: Construct, id: string, props: AppStackProps) {
|
||||
super(scope, id, props);
|
||||
const { domainName } = props;
|
||||
const { domainName, pagePaths } = props;
|
||||
|
||||
for (const pageName of pagePaths) {
|
||||
renameSync(
|
||||
path.resolve(__dirname, `../out/${pageName}.html`),
|
||||
path.resolve(__dirname, `../out/${pageName}`)
|
||||
);
|
||||
}
|
||||
|
||||
const mainBucket = new Bucket(this, "Bucket", {
|
||||
accessControl: BucketAccessControl.PRIVATE,
|
||||
@@ -47,6 +56,7 @@ export class AppStack extends cdk.Stack {
|
||||
exclude: ["engines"],
|
||||
}),
|
||||
],
|
||||
exclude: pagePaths,
|
||||
memoryLimit: 512,
|
||||
cacheControl: [
|
||||
CacheControl.setPublic(),
|
||||
@@ -54,6 +64,23 @@ export class AppStack extends cdk.Stack {
|
||||
],
|
||||
});
|
||||
|
||||
new BucketDeployment(this, "BucketPagesDeployment", {
|
||||
destinationBucket: mainBucket,
|
||||
sources: [
|
||||
Source.asset(path.resolve(__dirname, "../out"), {
|
||||
exclude: ["engines"],
|
||||
}),
|
||||
],
|
||||
exclude: ["*"],
|
||||
include: pagePaths,
|
||||
memoryLimit: 512,
|
||||
cacheControl: [
|
||||
CacheControl.setPublic(),
|
||||
CacheControl.maxAge(cdk.Duration.hours(1)),
|
||||
],
|
||||
contentType: "text/html",
|
||||
});
|
||||
|
||||
new BucketDeployment(this, "BucketEnginesDeployment", {
|
||||
destinationBucket: enginesBucket,
|
||||
destinationKeyPrefix: "engines",
|
||||
|
||||
@@ -6,4 +6,5 @@ const app = new cdk.App();
|
||||
new AppStack(app, "FreechessWebapp", {
|
||||
env: { region: "eu-west-3", account: process.env.CDK_DEFAULT_ACCOUNT },
|
||||
domainName: "chesskit.org",
|
||||
pagePaths: ["play", "database"],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user