Push 유효성 검사
API Endpoint
POST /api/push/test
푸시 서비스 구성과 VAPID 키 설정을 테스트합니다. 실제 푸시를 발송하지 않고 서비스 설정의 유효성을 확인할 수 있습니다.
엔드포인트: POST https://api.pushmanager.kr/api/push/test
POST /api/push/test
Content-Type: application/json
X-API-Key: <서비스-API-키>
Origin: <등록된-도메인>
Content-Type: application/json
X-API-Key: <서비스-API-키>
Origin: <등록된-도메인>
Parameters
이 엔드포인트는 요청 본문(body)이 필요하지 않습니다. 인증 헤더만으로 테스트를 수행합니다.
Discussion
이 엔드포인트는 서비스의 VAPID 키 구성이 올바른지 확인하고, 푸시 발송을 위한 모든 설정이 정상적으로 작동하는지 검증합니다. 실제 푸시 알림은 발송하지 않으므로 안전하게 테스트할 수 있습니다.
용도: 개발 및 디버깅 목적
실제 발송: 푸시 알림을 실제로 발송하지 않음
인증: 유효한 X-API-Key 헤더와 Origin 검증 필요
실제 발송: 푸시 알림을 실제로 발송하지 않음
인증: 유효한 X-API-Key 헤더와 Origin 검증 필요
응답 형식
성공 응답 (200 OK)
{
"success": true,
"message": "Push service test successful",
"data": {
"apiKey": "your-api-key",
"siteName": "내 웹사이트",
"vapidConfigured": true,
"testPayload": {
"title": "테스트 푸시 알림",
"body": "내 웹사이트에서 보낸 테스트 메시지입니다.",
"icon": "/icon-192x192.png",
"badge": "/badge-72x72.png",
"data": {
"timestamp": 1705312345678,
"test": true
}
},
"instructions": "Use this payload with your subscription data to test push notifications"
}
}
"success": true,
"message": "Push service test successful",
"data": {
"apiKey": "your-api-key",
"siteName": "내 웹사이트",
"vapidConfigured": true,
"testPayload": {
"title": "테스트 푸시 알림",
"body": "내 웹사이트에서 보낸 테스트 메시지입니다.",
"icon": "/icon-192x192.png",
"badge": "/badge-72x72.png",
"data": {
"timestamp": 1705312345678,
"test": true
}
},
"instructions": "Use this payload with your subscription data to test push notifications"
}
}
VAPID 설정 실패 (500 Internal Server Error)
{
"success": false,
"message": "VAPID configuration failed",
"code": "CONFIG_FAILED"
}
"success": false,
"message": "VAPID configuration failed",
"code": "CONFIG_FAILED"
}
사용 예시
// 푸시 서비스 테스트
const response = await fetch('https://api.pushmanager.kr/api/push/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your-api-key-here'
}
});
const result = await response.json();
if (result.success) {
console.log('푸시 서비스 설정이 정상입니다:', result.data);
} else {
console.error('푸시 서비스 설정 오류:', result.message);
}
const response = await fetch('https://api.pushmanager.kr/api/push/test', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'your-api-key-here'
}
});
const result = await response.json();
if (result.success) {
console.log('푸시 서비스 설정이 정상입니다:', result.data);
} else {
console.error('푸시 서비스 설정 오류:', result.message);
}