fix: drop the errors endpoint from the Bulwark Lite bundle for real

This commit is contained in:
Linus Rath
2026-11-01 04:40:16 +01:00
parent 79f73c5c84
commit 0ca60ee5d7
2 changed files with 6 additions and 9 deletions
@@ -1,16 +1,12 @@
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('@/lib/lite', async (importOriginal) => ({
...(await importOriginal<typeof import('@/lib/lite')>()),
IS_LITE: true,
}));
import { captureException, configureErrorReporting, resetErrorReportingForTests } from '../client';
const DSN = 'https://6f0b9c79ed3a4315b76595bc2536ac40@bugsink.example.org/3';
let fetchSpy: ReturnType<typeof vi.fn>;
beforeEach(() => {
vi.stubEnv('NEXT_PUBLIC_BULWARK_LITE', '1');
resetErrorReportingForTests();
sessionStorage.clear();
fetchSpy = vi.fn().mockResolvedValue(new Response(null, { status: 200 }));
@@ -18,6 +14,7 @@ beforeEach(() => {
});
afterEach(() => {
vi.unstubAllEnvs();
vi.unstubAllGlobals();
});
+4 -4
View File
@@ -1,5 +1,4 @@
import { apiFetch, getPathPrefix } from '@/lib/browser-navigation';
import { IS_LITE } from '@/lib/lite';
import { scrubRoutePath } from '@/lib/route-groups';
import { debugIdsByPath } from './debug-ids';
import {
@@ -201,9 +200,10 @@ function deliver(report: ErrorReport): void {
mode: 'cors',
});
}
// Lite has no server: the bundler drops this branch, and the endpoint
// with it (scripts/lite/verify.mjs fails on undocumented /api strings).
if (!IS_LITE && settings.collect) {
// Lite has no server. Read here, not through IS_LITE: the bundler inlines
// the variable only in this module, so the branch and the endpoint string
// leave the Lite bundle (scripts/lite/verify.mjs).
if (process.env.NEXT_PUBLIC_BULWARK_LITE !== '1' && settings.collect) {
send('/api/errors', JSON.stringify({
name: report.name,
message: report.message,