fix: Add basic user-agent to all mastodon-bound requests (#2277)

This commit is contained in:
Markus Unterwaditzer 2024-11-27 16:32:44 +01:00 committed by GitHub
parent 008248ee0f
commit 302da09248
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View file

@ -13,6 +13,7 @@ import { env } from '#build-info'
// @ts-expect-error virtual import
import { driver } from '#storage-config'
import { version } from '~/config/env'
import { APP_NAME } from '~/constants'
import type { AppInfo } from '~/types'
@ -48,9 +49,14 @@ export function getRedirectURI(origin: string, server: string) {
return `${origin}/api/${server}/oauth/${encodeURIComponent(origin)}`
}
export const defaultUserAgent = `${APP_NAME}/${version}`
async function fetchAppInfo(origin: string, server: string) {
const app: AppInfo = await $fetch(`https://${server}/api/v1/apps`, {
method: 'POST',
headers: {
'user-agent': defaultUserAgent,
},
body: {
client_name: APP_NAME + (env !== 'release' ? ` (${env})` : ''),
website: 'https://elk.zone',