shoc-frontend-new/infra/cdk/bin/app.ts
Alexandre Brandizzi 0b8d3fa290 feat(infra): call dev API directly, drop the CloudFront /api proxy
Adopt the direct cross-origin API approach (from feat/cd-cdk-fixes) now that the
dev backend allows CORS:

- VITE_API_URL=https://api.dev.seahaven.com/api (absolute, baked into the build)
- remove the CloudFront /api/* proxy behavior + HTTP origin; CloudFront serves
  static content only
- keep the custom domain (dev.seahaven.com), ACM cert, and Route 53 apex alias

VITE_API_URL is per-environment (baked at vite build), so staging/prod builds
must override it and the backend must allow their origins.
2026-07-06 15:03:54 -03:00

40 lines
1.4 KiB
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";
// Custom domain. Comma-separated, e.g. -c domainNames=dev.seahaven.com
// The ACM cert MUST be in us-east-1 in the SAME account this stack deploys to.
const domainNames = (app.node.tryGetContext("domainNames") ?? "")
.split(",")
.map((d: string) => d.trim())
.filter((d: string) => d.length > 0);
const certificateArn = app.node.tryGetContext("certificateArn") ?? "";
// Route 53 hosted zone (this account) for the custom-domain alias record.
const hostedZoneId = app.node.tryGetContext("hostedZoneId") ?? "";
const hostedZoneName = app.node.tryGetContext("hostedZoneName") ?? "";
const stack = new FrontendStack(app, `shoc-frontend-${envName}`, {
envName,
githubRepo,
deployBranch,
domainNames,
certificateArn,
hostedZoneId,
hostedZoneName,
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");