Skip to content

Commit e03cdc6

Browse files
committed
Gracefully degrade to non-prerendered content on timeout
1 parent 6338045 commit e03cdc6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/OriginRequestInterface.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,19 @@ module.exports = class OriginRequestInterface {
9898
return res;
9999
}
100100
createNext() {
101+
// this flow will be called for prerender.cloud LAST_RESORT_TIMEOUT
102+
// aka "prerendercloud middleware SKIPPED: server error: Request timed out"
103+
// it will merely fall back to non-prerendered content
101104
return () => {
102105
delete this.cloudFrontRequest.headers[util.USER_AGENT_PLACEHOLDER];
103-
this.cloudFrontRequest.uri = this.originalUri;
104106

107+
if (this.originalUri === "/") {
108+
this.cloudFrontRequest.uri = "/index.html";
109+
} else {
110+
this.cloudFrontRequest.uri = this.originalUri;
111+
}
112+
113+
// console.log("OriginRequest calling next", this.cloudFrontRequest);
105114
this.callback(null, this.cloudFrontRequest);
106115
};
107116
}

0 commit comments

Comments
 (0)