xiaohongshu
xiaohongshu
domain-management
Configure domain routing and Cloudflare DNS for sgcarstrends.com and subdomains. Use when adding new services, updating domain patterns, or debugging DNS issues.
Full skill instructions
This skill helps you manage domains and DNS configuration for the SG Cars Trends platform.
sgcarstrends.com # Production web app
staging.sgcarstrends.com # Staging web app
dev.sgcarstrends.com # Development web app
api.sgcarstrends.com # Production API
api.staging.sgcarstrends.com # Staging API
api.dev.sgcarstrends.com # Development API
docs.sgcarstrends.com # Documentation (future)
Web Apps:
sgcarstrends.com){stage}.sgcarstrends.comBackend Services:
{service}.{stage}.sgcarstrends.com{service}.sgcarstrends.com (no stage prefix)Examples:
api.sgcarstrends.com # Production API
api.staging.sgcarstrends.com # Staging API
websocket.sgcarstrends.com # Production WebSocket service
websocket.dev.sgcarstrends.com # Dev WebSocket service
Cloudflare manages DNS records, AWS Route53 is for SSL certificate validation only.
// infra/dns.ts
import { StackContext } from "sst/constructs";
import * as route53 from "aws-cdk-lib/aws-route53";
export function DNS({ stack }: StackContext) {
// Import existing hosted zone (created in Route53)
const hostedZone = route53.HostedZone.fromLookup(stack, "HostedZone", {
domainName: "sgcarstrends.com",
});
stack.addOutputs({
HostedZoneId: hostedZone.hostedZoneId,
HostedZoneName: hostedZone.zoneName,
});
return { hostedZone };
}
// infra/web.ts
import { StackContext, NextjsSite, use } from "sst/constructs";
import { DNS } from "./dns";
export function Web({ stack, app }: StackContext) {
const { hostedZone } = use(DNS);
const web = new NextjsSite(stack, "web", {
path: "apps/web",
customDomain: {
domainName: app.stage === "production"
? "sgcarstrends.com" // Apex domain for prod
: `${app.stage}.sgcarstrends.com`, // Subdomain for others
hostedZone: hostedZone.zoneName,
},
});
stack.addOutputs({
WebUrl: web.url,
WebDomain: web.customDomainUrl,
});
return { web };
}
// infra/api.ts
import { StackContext, Function, use } from "sst/constructs";
import { DNS } from "./dns";
export function API({ stack, app }: StackContext) {
const { hostedZone } = use(DNS);
const api = new Function(stack, "api", {
handler: "apps/api/src/index.handler",
url: {
domain: {
domainName: app.stage === "production"
? "api.sgcarstrends.com"
: `api.${app.stage}.sgcarstrends.com`,
hostedZone: hostedZone.zoneName,
},
},
});
stack.addOutputs({
ApiUrl: api.url,
ApiDomain: api.url,
});
return { api };
}
Cloudflare DNS records point to AWS CloudFront or Lambda Function URLs:
Type Name Value Proxy
CNAME sgcarstrends.com d111111abcdef8.cloudfront.net ✓ Proxied
CNAME staging d222222abcdef8.cloudfront.net ✓ Proxied
CNAME dev d333333abcdef8.cloudfront.net ✓ Proxied
CNAME api abc123.lambda-url.ap-southeast-1.on.aws ✓ Proxied
CNAME api.staging def456.lambda-url.ap-southeast-1.on.aws ✓ Proxied
Encryption Mode: Full (strict)
Edge Certificates:
*.sgcarstrends.com and sgcarstrends.comRule 1: Cache API responses
URL: api.sgcarstrends.com/*
Settings:
- Cache Level: Standard
- Edge Cache TTL: 1 hour
Rule 2: Always use HTTPS
URL: *sgcarstrends.com/*
Settings:
- Always Use HTTPS: On
Rule 3: Security headers
URL: sgcarstrends.com/*
Settings:
- Security Headers: On
- HSTS: Enabled
SST automatically requests certificates from ACM:
// Automatic when using customDomain
const web = new NextjsSite(stack, "web", {
customDomain: {
domainName: "sgcarstrends.com",
hostedZone: hostedZone.zoneName,
},
});
// SST will:
// 1. Request certificate from ACM
// 2. Add DNS validation records to Route53
// 3. Wait for validation
// 4. Attach certificate to CloudFront/Lambda
If needed:
# Request certificate
aws acm request-certificate \
--domain-name sgcarstrends.com \
--subject-alternative-names *.sgcarstrends.com \
--validation-method DNS \
--region us-east-1 # CloudFront requires us-east-1
# Get validation records
aws acm describe-certificate \
--certificate-arn arn:aws:acm:... \
--region us-east-1
Add validation CNAME records to Cloudflare DNS.
// infra/new-service.ts
import { StackContext, Function, use } from "sst/constructs";
import { DNS } from "./dns";
export function NewService({ stack, app }: StackContext) {
const { hostedZone } = use(DNS);
const service = new Function(stack, "new-service", {
handler: "apps/new-service/src/index.handler",
url: {
domain: {
domainName: app.stage === "production"
? "newservice.sgcarstrends.com"
: `newservice.${app.stage}.sgcarstrends.com`,
hostedZone: hostedZone.zoneName,
},
},
});
return { service };
}
npx sst deploy --stage production
SST will:
Get the AWS URL from SST outputs, then:
sgcarstrends.com domainnewservice (or newservice.staging)# Check DNS resolution
dig newservice.sgcarstrends.com
# Test HTTPS
curl -I https://newservice.sgcarstrends.com
# Check Cloudflare DNS
dig @1.1.1.1 sgcarstrends.com
dig @1.1.1.1 api.sgcarstrends.com
# Check global propagation
dig sgcarstrends.com @8.8.8.8 # Google DNS
dig sgcarstrends.com @1.1.1.1 # Cloudflare DNS
# Or use online tools
# https://www.whatsmydns.net/#CNAME/api.sgcarstrends.com
# Check certificate details
openssl s_client -connect sgcarstrends.com:443 -servername sgcarstrends.com
# Check certificate expiry
echo | openssl s_client -connect sgcarstrends.com:443 -servername sgcarstrends.com 2>/dev/null | openssl x509 -noout -dates
# Test HTTP → HTTPS redirect
curl -I http://sgcarstrends.com
# Test HTTPS
curl -I https://sgcarstrends.com
# Test API endpoint
curl -I https://api.sgcarstrends.com/health
Issue: DNS not resolving Solutions:
Issue: SSL certificate error Solutions:
Issue: 522 error (Connection timed out) Solutions:
Issue: Redirecting to wrong domain Solutions:
customDomain configurationWhen API and Web are on different domains:
// apps/api/src/index.ts
import { Hono } from "hono";
import { cors } from "hono/cors";
const app = new Hono();
app.use("/*", cors({
origin: [
"https://sgcarstrends.com",
"https://staging.sgcarstrends.com",
"https://dev.sgcarstrends.com",
"http://localhost:3001", // Local development
],
credentials: true,
}));
View:
// infra/monitoring.ts
import { StackContext } from "sst/constructs";
import * as route53 from "aws-cdk-lib/aws-route53";
export function Monitoring({ stack }: StackContext) {
new route53.CfnHealthCheck(stack, "ApiHealthCheck", {
healthCheckConfig: {
type: "HTTPS",
fullyQualifiedDomainName: "api.sgcarstrends.com",
port: 443,
resourcePath: "/health",
requestInterval: 30,
failureThreshold: 3,
},
});
}
customDomain: {
domainName: "new-domain.com",
hostedZone: newHostedZone.zoneName,
}
// Cloudflare page rule
URL: old-domain.com/*
Forwarding URL: 301 - https://new-domain.com/$1
The project uses apex domain (sgcarstrends.com) for production:
Advantages:
Challenges:
Cloudflare automatically flattens CNAMEs at apex:
# This works with Cloudflare:
CNAME sgcarstrends.com → d111111abcdef8.cloudfront.net
# Cloudflare resolves it to:
A sgcarstrends.com → 104.21.x.x
A sgcarstrends.com → 172.67.x.x
Web apps:
sgcarstrends.com # Production
staging.sgcarstrends.com # Staging
dev.sgcarstrends.com # Development
API:
api.sgcarstrends.com # Production
api.staging... # Staging
api.dev... # Development
Future:
docs.sgcarstrends.com # Documentation
status.sgcarstrends.com # Status page
Follow the pattern:
{service}.sgcarstrends.com{service}.{stage}.sgcarstrends.comConfigure in Cloudflare or application:
// apps/web/next.config.js
const securityHeaders = [
{
key: "X-DNS-Prefetch-Control",
value: "on",
},
{
key: "Strict-Transport-Security",
value: "max-age=63072000; includeSubDomains; preload",
},
{
key: "X-Frame-Options",
value: "SAMEORIGIN",
},
{
key: "X-Content-Type-Options",
value: "nosniff",
},
{
key: "Referrer-Policy",
value: "origin-when-cross-origin",
},
];
const nextConfig = {
async headers() {
return [
{
source: "/:path*",
headers: securityHeaders,
},
];
},
};
infra/dns.ts - DNS configurationinfra/CLAUDE.md - Infrastructure documentation{service}.{stage}.domain patternxiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience