mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2026-09-27 04:51:45 +00:00
`ServeDir::not_found_service` wraps the fallback in `SetStatus`, which forces every response to `404 Not Found`. Client side routes such as `/note/<id>` and `/about` were therefore served the correct `index.html` but with a 404 status. Use `ServeDir::fallback` instead, which leaves the status untouched. A note that genuinely does not exist is still reported as 404 by `/api/notes/<id>`. Behind a reverse proxy this made effectively every document request show up as a 4xx, skewing error rate dashboards and triggering false alerts. Fixes #217
20 lines
765 B
TypeScript
20 lines
765 B
TypeScript
import { expect, test } from '@playwright/test'
|
|
|
|
// The SPA fallback serves index.html for client side routes. The document is
|
|
// served successfully, so it must not be reported as 404.
|
|
// A missing note is signalled by the API on /api/notes/<id> instead.
|
|
// https://github.com/cupcakearmy/cryptgeon/issues/217
|
|
test.describe('@web', () => {
|
|
for (const path of ['/', '/about', '/note/does-not-exist']) {
|
|
test(`serves ${path} with status 200`, async ({ request }) => {
|
|
const response = await request.get(path)
|
|
expect(response.status()).toBe(200)
|
|
})
|
|
}
|
|
|
|
test('api still reports a missing note as 404', async ({ request }) => {
|
|
const response = await request.get('/api/notes/does-not-exist')
|
|
expect(response.status()).toBe(404)
|
|
})
|
|
})
|