mirror of
https://github.com/Sea-Haven-Industries/shoc-frontend-new.git
synced 2026-10-07 16:19:01 +00:00
The SPA is served over HTTPS by CloudFront but the backend (console.seahavenind.com) is HTTP-only, so direct API calls would be blocked as mixed content. Add a CloudFront /api/* behavior that proxies to the backend over HTTP (browser <-> CloudFront is HTTPS; CloudFront <-> origin is HTTP) and set VITE_API_URL=/api (same-origin). Because distribution-level customErrorResponses are global and would rewrite real /api 403/404s into the SPA shell, replace them with a viewer-request CloudFront Function scoped to the S3 (default) behavior that rewrites extensionless paths to /index.html. /api/* carries no function association. Backend host is configurable via `-c apiOriginDomain=<host>` (default console.seahavenind.com). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
26 lines
925 B
JavaScript
26 lines
925 B
JavaScript
#!/usr/bin/env node
|
|
import { App, Tags } from "aws-cdk-lib";
|
|
import { FrontendStack } from "../lib/frontend-stack";
|
|
|
|
const app = new App();
|
|
|
|
// Defaults match the dev setup; override via `-c key=value` on the CLI.
|
|
const envName = app.node.tryGetContext("envName") ?? "dev";
|
|
const githubRepo = app.node.tryGetContext("githubRepo") ?? "Sea-Haven-Industries/shoc-frontend-new";
|
|
const deployBranch = app.node.tryGetContext("deployBranch") ?? "dev";
|
|
const apiOriginDomain = app.node.tryGetContext("apiOriginDomain") ?? "console.seahavenind.com";
|
|
|
|
const stack = new FrontendStack(app, `shoc-frontend-${envName}`, {
|
|
envName,
|
|
githubRepo,
|
|
deployBranch,
|
|
apiOriginDomain,
|
|
env: {
|
|
account: process.env.CDK_DEFAULT_ACCOUNT,
|
|
region: process.env.CDK_DEFAULT_REGION ?? "us-east-1",
|
|
},
|
|
});
|
|
|
|
Tags.of(stack).add("Project", "shoc-frontend");
|
|
Tags.of(stack).add("Environment", envName);
|
|
Tags.of(stack).add("ManagedBy", "cdk");
|