-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Expand file tree
/
Copy pathvercel.ts
More file actions
57 lines (54 loc) · 1.59 KB
/
vercel.ts
File metadata and controls
57 lines (54 loc) · 1.59 KB
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
49
50
51
52
53
54
55
56
57
import { matchers, routes, type VercelConfig } from "@vercel/config/v1";
const ROUTER_HOST = "app.t3.codes";
const HOSTED_WEB_CHANNEL_COOKIE = "t3code_web_channel";
const LATEST_ORIGIN = "https://latest.app.t3.codes";
const NIGHTLY_ORIGIN = "https://nightly.app.t3.codes";
function channelCookie(channel: "latest" | "nightly"): string {
return [
`${HOSTED_WEB_CHANNEL_COOKIE}=${channel}`,
"Path=/",
"Max-Age=31536000",
"HttpOnly",
"Secure",
"SameSite=Lax",
].join("; ");
}
export const config: VercelConfig = {
buildCommand:
'turbo build --filter @t3tools/web && bun ../../scripts/apply-web-brand-assets.ts --channel "${VITE_HOSTED_APP_CHANNEL:-latest}"',
git: {
deploymentEnabled: false,
},
installCommand:
"bun add -g turbo && bun install --filter '@t3tools/contracts' --filter '@t3tools/client-runtime' --filter '@t3tools/scripts' --filter '@t3tools/web'",
routes: [
{
src: "/__t3code/channel",
has: [matchers.query("channel", "nightly")],
headers: {
Location: "/",
"Set-Cookie": channelCookie("nightly"),
},
status: 302,
},
{
src: "/__t3code/channel",
headers: {
Location: "/",
"Set-Cookie": channelCookie("latest"),
},
status: 302,
},
{
src: "/(.*)",
has: [matchers.host(ROUTER_HOST), matchers.cookie(HOSTED_WEB_CHANNEL_COOKIE, "nightly")],
dest: `${NIGHTLY_ORIGIN}/$1`,
},
{
src: "/(.*)",
has: [matchers.host(ROUTER_HOST)],
dest: `${LATEST_ORIGIN}/$1`,
},
],
rewrites: [routes.rewrite("/(.*)", "/index.html")],
};