Files
medical-mall/server/probe_supa.js
not-like-juvenile 08a0408b0e 测试文件
2026-02-26 09:54:21 +08:00

29 lines
1.1 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
const fetch = require('node-fetch')
const SUPA = process.env.SUPA_URL || process.env.SUPA || 'http://192.168.1.62:18000'
// 支持两种环境变量名SUPA_KEY 或 SERVICE_ROLE_KEY自托管 .env 里常见)
const KEY = process.env.SUPA_KEY || process.env.SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoic2VydmljZV9yb2xlIiwiaXNzIjoic3VwYWJhc2UtMSIsImlhdCI6MTc3MTk4OTAwNywiZXhwIjoxODAzNTI1MDA3fQ.TBZeJIYEGdcKMMXAAJAka-09c4hO8_e_wyW8V5tkJ2Y';
const USER = 'a8e3a568-fc1f-4237-bcc5-5722e2fca0a3';
(async () => {
try {
const url = `${SUPA.replace(/\/$/, '')}/rest/v1/push_devices?user_id=eq.${encodeURIComponent(USER)}`
console.log('GET', url)
const resp = await fetch(url, {
method: 'GET',
headers: {
apikey: KEY,
Authorization: `Bearer ${KEY}`,
Accept: 'application/json'
},
timeout: 10000
})
console.log('status', resp.status)
const txt = await resp.text()
console.log('body:', txt)
} catch (e) {
console.error('probe error', e && e.message ? e.message : e)
process.exit(1)
}
})()