-
Notifications
You must be signed in to change notification settings - Fork 0
/
sst.config.ts
48 lines (48 loc) · 1.19 KB
/
sst.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/// <reference path="./.sst/platform/config.d.ts" />
import { API_TOKEN } from "./cloudflare";
export default $config({
app(input) {
return {
name: "mmc-frontend",
stage: input?.stage || "dev", // 确保有默认的 stage
removal: input?.stage === "production" ? "retain" : "remove",
home: "aws",
providers: {
cloudflare: {
apiToken: API_TOKEN,
},
},
};
},
async run() {
// 获取当前 stage
console.log("Current stage:", $app.stage);
new sst.aws.Nextjs("mmc-frontend", {
environment: {
STAGE: $app.stage, // 将 stage 传递给 Next.js 应用
},
domain: {
name: "mmc.maomaocong.site",
dns: sst.cloudflare.dns(),
},
server: {
edge: {
viewerRequest: {
injection: `
event.request.headers["x-custom-header"] = {
value: "custom-value"
};
`,
},
viewerResponse: {
injection: `
event.response.headers["x-response-header"] = {
value: "edge-processed"
};
`,
},
},
},
});
},
});