Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
publish = "dist"
command = "npm run build"

# Netlify Functions live in netlify/functions/ (this is Netlify's default,
# stated explicitly for clarity).
[functions]
directory = "netlify/functions"

# QA-only: expose the qa-status function at the clean path /qa-status so
# Prerender sees a normal-looking page URL. Must be declared BEFORE the
# SPA catch-all below, otherwise /* swallows it. status = 200 is a Netlify
# rewrite (proxy), which preserves the upstream function's actual status
# code (200 or 500) — it does NOT force a 200 response.
[[redirects]]
from = "/qa-status"
to = "/.netlify/functions/qa-status"
status = 200

# Redirect all requests to /index.html for SPA routing
[[redirects]]
from = "/*"
Expand Down
45 changes: 45 additions & 0 deletions netlify/functions/qa-status.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// QA-only Netlify Function used to test Prerender's error -> recovery (cache
// refresh) flow. Toggle the HTTP status across deploys via the Netlify env
// var QA_FORCE_500:
// QA_FORCE_500="true" -> HTTP 500, plain text body
// anything else/unset -> HTTP 200, minimal HTML page
// Reached publicly via /qa-status (see redirect in netlify.toml).

export default async (_req: Request): Promise<Response> => {
if (process.env.QA_FORCE_500 === "true") {
const errorHtml = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>500 - QA</title>
</head>
<body>
<h1>Server Error</h1>
</body>
</html>
`;
return new Response(errorHtml, {
status: 500,
headers: { "Content-Type": "text/html; charset=utf-8" },
});
}

const html = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>QA Status Test</title>
</head>
<body>
<h1>QA Status Test</h1>
</body>
</html>
`;

return new Response(html, {
status: 200,
headers: { "Content-Type": "text/html; charset=utf-8" },
});
};
Loading