Fix: Added detailed VAPID debugging and unauthenticated status endpoint
This commit is contained in:
parent
0eab4b36e7
commit
4fc255b144
@ -4,6 +4,13 @@ import { getUsersForRemindersD1, updateLastNotifiedD1 } from '@/lib/d1';
|
|||||||
|
|
||||||
// Configure web-push - Helper called inside handler to ensure env is ready
|
// Configure web-push - Helper called inside handler to ensure env is ready
|
||||||
function ensureVapidConfig() {
|
function ensureVapidConfig() {
|
||||||
|
console.log('--- VAPID Debug ---');
|
||||||
|
console.log('VAPID_PUBLIC:', process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY ? `Present (Starts with: ${process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY.substring(0, 5)}...)` : 'MISSING');
|
||||||
|
console.log('VAPID_PRIVATE:', process.env.VAPID_PRIVATE_KEY ? 'Present' : 'MISSING');
|
||||||
|
console.log('VAPID_SUBJECT:', process.env.VAPID_SUBJECT || 'MISSING (Defaulting to mailto:admin@quittraq.com)');
|
||||||
|
console.log('Available Env Keys:', Object.keys(process.env).filter(k => k.includes('VAPID') || k.includes('KEY')));
|
||||||
|
console.log('-------------------');
|
||||||
|
|
||||||
if (process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY && process.env.VAPID_PRIVATE_KEY) {
|
if (process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY && process.env.VAPID_PRIVATE_KEY) {
|
||||||
webPush.setVapidDetails(
|
webPush.setVapidDetails(
|
||||||
process.env.VAPID_SUBJECT || 'mailto:example@yourdomain.org',
|
process.env.VAPID_SUBJECT || 'mailto:example@yourdomain.org',
|
||||||
@ -198,7 +205,16 @@ export async function GET(request: NextRequest) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NextResponse.json({ success: true, processed });
|
return NextResponse.json({
|
||||||
|
success: true,
|
||||||
|
vapid: {
|
||||||
|
ready: isVapidReady,
|
||||||
|
public_present: !!process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY,
|
||||||
|
private_present: !!process.env.VAPID_PRIVATE_KEY,
|
||||||
|
env_keys: Object.keys(process.env).filter(k => k.includes('VAPID'))
|
||||||
|
},
|
||||||
|
processed
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Cron error:', error);
|
console.error('Cron error:', error);
|
||||||
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
return NextResponse.json({ error: 'Internal server error' }, { status: 500 });
|
||||||
|
|||||||
12
src/app/api/debug/vapid/route.ts
Normal file
12
src/app/api/debug/vapid/route.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { NextResponse } from 'next/server';
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
return NextResponse.json({
|
||||||
|
vapid: {
|
||||||
|
public_present: !!process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY,
|
||||||
|
private_present: !!process.env.VAPID_PRIVATE_KEY,
|
||||||
|
subject_present: !!process.env.VAPID_SUBJECT,
|
||||||
|
env_keys: Object.keys(process.env).filter(k => k.includes('VAPID'))
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user