forked from tempoxyz/mpp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvercel.mjs
More file actions
96 lines (87 loc) · 2.59 KB
/
Copy pathvercel.mjs
File metadata and controls
96 lines (87 loc) · 2.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
const DOC_DISCOVERY_LINK_VALUE = [
'</.well-known/api-catalog>; rel="api-catalog"; type="application/linkset+json"',
'</.well-known/mcp.json>; rel="describedby"; type="application/json"',
'</.well-known/agent-skills/index.json>; rel="describedby"; type="application/json"',
'</llms.txt>; rel="alternate"; type="text/plain"',
'</llms-full.txt>; rel="alternate"; type="text/plain"',
].join(", ");
const OPENAPI_DISCOVERY_LINK_VALUE = [
'</.well-known/api-catalog>; rel="api-catalog"; type="application/linkset+json"',
'</.well-known/mcp.json>; rel="describedby"; type="application/json"',
'</.well-known/agent-skills/index.json>; rel="describedby"; type="application/json"',
].join(", ");
const CONTENT_NEGOTIATION_HEADERS = [header("Vary", "Accept, User-Agent")];
const API_CATALOG_HEADERS = [
header("Access-Control-Allow-Origin", "*"),
header("Cache-Control", "public, max-age=300"),
header(
"Content-Type",
'application/linkset+json; profile="https://www.rfc-editor.org/info/rfc9727"',
),
header(
"Link",
'</.well-known/api-catalog>; rel="api-catalog"; type="application/linkset+json"',
),
header("X-Content-Type-Options", "nosniff"),
];
const CACHE_HEADERS = [
header("Cache-Control", "public, max-age=300"),
header("X-Content-Type-Options", "nosniff"),
];
const DOC_SECTIONS = [
"advanced",
"guides",
"overview",
"payment-methods",
"protocol",
"quickstart",
"sdk",
"services",
"tools",
"use-cases",
];
const DISCOVERY_PAGE_SOURCES = [
"/",
...DOC_SECTIONS.flatMap((section) => [`/${section}`, `/${section}/:path*`]),
];
export const config = {
headers: [
headerRule("/.well-known/api-catalog", API_CATALOG_HEADERS),
headerRule("/.well-known/:path*", [
header("Access-Control-Allow-Origin", "*"),
...CACHE_HEADERS,
]),
headerRule("/robots.txt", CACHE_HEADERS),
headerRule("/openapi.json", [header("Link", OPENAPI_DISCOVERY_LINK_VALUE)]),
...DISCOVERY_PAGE_SOURCES.map((source) =>
headerRule(source, [
header("Link", DOC_DISCOVERY_LINK_VALUE),
...CONTENT_NEGOTIATION_HEADERS,
]),
),
],
redirects: [
{
source: "/index",
destination: "/",
permanent: true,
},
{
source: "/openapi.json",
destination: "/api/openapi.json",
permanent: false,
},
{
source: "/:path(.*)",
has: [{ type: "host", value: "mpp.tempo.xyz" }],
destination: "https://mpp.dev/:path",
permanent: true,
},
],
};
function header(key, value) {
return { key, value };
}
function headerRule(source, headers) {
return { source, headers };
}