Skip to content

Commit 8b0f8ef

Browse files
committed
add headers for serve
1 parent 6d7f4ee commit 8b0f8ef

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ export class StaticRouters {
9595
console.error(error, errorInfo);
9696
},
9797
noStreaming,
98+
headers,
9899
staticHeaders,
99100
staticProps,
100101
}: {
@@ -104,6 +105,7 @@ export class StaticRouters {
104105
context?: T;
105106
onError?(error: unknown, errorInfo: React.ErrorInfo): string | void;
106107
noStreaming?: boolean;
108+
headers?: HeadersInit;
107109
staticHeaders?: HeadersInit;
108110
staticProps?: Record<string, unknown>;
109111
}
@@ -135,13 +137,14 @@ export class StaticRouters {
135137
headers: {
136138
"Content-Type": "application/vnd.server-side-props",
137139
"Cache-Control": "no-store",
140+
...headers,
138141
},
139142
});
140143
}
141144
if (result?.redirect) {
142145
return new Response(null, {
143146
status: 302,
144-
headers: { Location: result.redirect },
147+
headers: { Location: result.redirect, ...headers },
145148
});
146149
}
147150
const hashedBootstrapModules = bootstrapModules?.map((name) => {
@@ -184,13 +187,15 @@ export class StaticRouters {
184187
headers: {
185188
"Content-Type": "text/html; charset=utf-8",
186189
"Cache-Control": "no-store",
190+
...headers,
187191
},
188192
});
189193
}
190194
return new Response(stream, {
191195
headers: {
192196
"Content-Type": "text/html; charset=utf-8",
193197
"Cache-Control": "no-store",
198+
...headers,
194199
},
195200
});
196201
}

0 commit comments

Comments
 (0)