Compare commits

...

2 Commits

Author SHA1 Message Date
c1cad7b99b 2.4.36
All checks were successful
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🚀 Deploy (push) Successful in 27s
Build & Deploy / 🧪 QA (push) Successful in 1m18s
Build & Deploy / 🏗️ Build (push) Successful in 2m27s
Build & Deploy / 🧪 Post-Deploy Verification (push) Successful in 50s
Build & Deploy / 🔔 Notify (push) Successful in 4s
2026-07-18 09:42:24 +02:00
cbda41ee95 fix: use https.request with rejectUnauthorized to bypass internal CA fetch errors 2026-07-18 09:42:24 +02:00
2 changed files with 40 additions and 15 deletions

View File

@@ -1,4 +1,5 @@
import { NextResponse } from 'next/server';
import https from 'https';
const ALLOWED_HOSTS = ['glitchtip.infra.mintel.me', 'errors.infra.mintel.me'];
@@ -36,21 +37,45 @@ export async function POST(req: Request) {
const sentryIngestUrl = `https://${host}/api/${projectId}/envelope/`;
const payloadToForward = items.join('\n');
const response = await fetch(sentryIngestUrl, {
method: 'POST',
body: payloadToForward,
headers: {
'Content-Type': 'application/x-sentry-envelope',
},
return new Promise<NextResponse>((resolve) => {
const req = https.request(
sentryIngestUrl,
{
method: 'POST',
headers: {
'Content-Type': 'application/x-sentry-envelope',
},
// Bypass self-signed cert error since glitchtip.infra.mintel.me uses an internal CA
// that the Next.js docker container doesn't trust by default.
rejectUnauthorized: false,
},
(res) => {
res.on('data', () => {
// Consume data to free up memory
});
res.on('end', () => {
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
resolve(NextResponse.json({ success: true }));
} else {
resolve(
NextResponse.json(
{ error: `Relay rejected (${res.statusCode})` },
{ status: res.statusCode || 500 }
)
);
}
});
}
);
req.on('error', (err) => {
console.error('[Sentry Tunnel] https.request failed', err);
resolve(NextResponse.json({ error: 'Relay failed' }, { status: 500 }));
});
req.write(payloadToForward);
req.end();
});
if (!response.ok) {
const errorText = await response.text();
console.error(`[Sentry Tunnel] Relay rejected (${response.status}):`, errorText);
return NextResponse.json({ error: 'Sentry rejection' }, { status: response.status });
}
return NextResponse.json({ success: true });
} catch (e) {
console.error("[Sentry Tunnel] Failed to parse or relay body", e);
return NextResponse.json({ error: 'Relay failed' }, { status: 500 });

View File

@@ -140,7 +140,7 @@
"prepare": "husky",
"preinstall": "npx only-allow pnpm"
},
"version": "2.4.35",
"version": "2.4.36",
"pnpm": {
"onlyBuiltDependencies": [
"@parcel/watcher",