Skip to content

Commit 751d35d

Browse files
committed
edit
1 parent 0ce324d commit 751d35d

File tree

3 files changed

+10
-26
lines changed

3 files changed

+10
-26
lines changed

custom-redirect.js

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,14 @@ let errorGif = "";
1010
const REDIRECT = {
1111
/**
1212
* Generates HTML content with appropriate Canva URL
13-
* @param {boolean} enableReportError - Whether to include the report button
1413
* @returns {string} The HTML with injected URL
1514
*/
16-
generateErrorPage: (enableReportError = false) => {
17-
let page = errorTemplate
18-
.replace('ERROR_CODE', errorCode)
19-
.replace('ERROR_TYPE', errorType)
20-
.replace('ERROR_MESSAGE', errorMessage)
21-
.replace('ERROR_GIF', errorGif);
22-
23-
if (!enableReportError) {
24-
page = page.replace(
25-
/<!-- BEGIN_REPORT_BUTTON -->.*?<!-- END_REPORT_BUTTON -->/s,
26-
''
27-
);
28-
}
29-
30-
return page;
15+
generateErrorPage: () => {
16+
return errorTemplate
17+
.replace('ERROR_CODE', errorCode)
18+
.replace('ERROR_TYPE', errorType)
19+
.replace('ERROR_MESSAGE', errorMessage)
20+
.replace('ERROR_GIF', errorGif);
3121
}
3222
};
3323

html/error-template.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
<div id="error-message" class="error-message">ERROR_MESSAGE</div>
2323
<img class="gif" src="ERROR_GIF" alt="Error illustration">
2424
<!-- Conditionally render the report button -->
25+
<!-- If ENABLE_REPORT_ERROR is true, render the button -->
26+
<!-- Placeholder for server-side rendering -->
2527
<!-- BEGIN_REPORT_BUTTON -->
26-
<!-- The button will only be rendered if ENABLE_REPORT_ERROR is true -->
27-
<!-- This placeholder will be dynamically replaced server-side -->
28+
<button id="open-report-modal" class="report-btn" data-link="" data-site="">Signaler cette erreur</button>
2829
<!-- END_REPORT_BUTTON -->
2930
</div>
3031
<!-- Embedded front-end script for modal and reporting -->
@@ -193,4 +194,3 @@
193194
</script>
194195
</body>
195196
</html>
196-
</html>

worker.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,7 @@ export default {
158158

159159
// Custom error page
160160
const redirectResponse = await c_redirect(request, response, null, isMaintenance, env);
161-
if (redirectResponse) {
162-
const enableReportError = env.ENABLE_REPORT_ERROR === true;
163-
return new Response(REDIRECT.generateErrorPage(enableReportError), {
164-
status: response?.status || 500,
165-
headers: { 'Content-Type': 'text/html' }
166-
});
167-
}
161+
if (redirectResponse) return redirectResponse;
168162

169163
// Banner injection - check for 4G mode or regular banner
170164
let showBanner = false;

0 commit comments

Comments
 (0)