spot: fix url builder for refresh req

This commit is contained in:
nick-delirium 2024-08-30 11:11:12 +02:00
parent 332ffa3ca0
commit 3a14e0f7ce
No known key found for this signature in database
GPG key ID: 93ABD695DF5FDBA0

View file

@ -247,14 +247,15 @@ export default defineBackground(() => {
}
});
async function pingJWT(refreshUrl: string): Promise<void> {
async function pingJWT(ingest: string): Promise<void> {
const refreshUrl = safeApiUrl(`${ingest}/api/refresh`);
if (!jwtToken) {
if (pingInt) {
clearInterval(pingInt);
}
return;
}
const url = safeApiUrl(`${settings.ingestPoint}/spot/v1/ping`);
const url = safeApiUrl(`${ingest}/spot/v1/ping`);
try {
const r = await fetch(url, {
method: "GET",
@ -461,7 +462,7 @@ export default defineBackground(() => {
}
if (!pingInt) {
pingInt = setInterval(() => {
void pingJWT(url);
void pingJWT(data.settings.ingestPoint);
}, PING_INT)
}
});
@ -762,7 +763,7 @@ export default defineBackground(() => {
const ingestUrl = safeApiUrl(settings.ingestPoint);
const dataUrl = `${ingestUrl}/spot/v1/spots`;
refreshToken(ingestUrl).then((r) => {
refreshToken(ingestUrl + '/api').then((r) => {
if (!r) {
void sendToActiveTab({
type: messages.content.to.notification,