use consistent user agent for requests

This commit is contained in:
austinried
2021-09-08 15:49:01 +09:00
parent 51f79ac8ad
commit eb578fa5e6
3 changed files with 9 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ import {
SubsonicResponse,
} from '@app/subsonic/responses'
import toast from '@app/util/toast'
import userAgent from '@app/util/userAgent'
import { DOMParser } from 'xmldom'
export class SubsonicApiError extends Error {
@@ -85,7 +86,9 @@ export class SubsonicApiClient {
let text: string
try {
const response = await fetch(this.buildUrl(method, params))
const response = await fetch(this.buildUrl(method, params), {
headers: { 'User-Agent': userAgent },
})
text = await response.text()
} catch (err) {
toast(`Network error: ${this.address}`)