Skip to content

Commit f1ae983

Browse files
committed
Output a x-gitbook-route-type header to distinguish static/dynamic
1 parent bb3ca9c commit f1ae983

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/gitbook-v2/src/middleware.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ async function serveSiteByURL(request: NextRequest, urlWithMode: URLWithMode) {
108108
requestHeaders.set('x-forwarded-host', request.nextUrl.host);
109109
requestHeaders.set('origin', request.nextUrl.origin);
110110

111+
const siteURL = `${url.host}${data.basePath}`;
112+
111113
const route = [
112114
'sites',
113115
routeType,
114116
mode,
115-
encodeURIComponent(url.host + data.basePath),
117+
encodeURIComponent(siteURL),
116118
encodePathInSiteContent(data.pathname),
117119
].join('/');
118120

@@ -131,6 +133,9 @@ async function serveSiteByURL(request: NextRequest, urlWithMode: URLWithMode) {
131133
response.headers.set('strict-transport-security', 'max-age=31536000');
132134
response.headers.set('referrer-policy', 'no-referrer-when-downgrade');
133135
response.headers.set('x-content-type-options', 'nosniff');
136+
// Debug header
137+
response.headers.set('x-gitbook-route-type', routeType);
138+
response.headers.set('x-gitbook-site-url', siteURL);
134139

135140
if (visitorToken) {
136141
const cookies = getResponseCookiesForVisitorAuth(data.basePath, visitorToken);

0 commit comments

Comments
 (0)