fix: Add basic user-agent to all mastodon-bound requests (#2277)
This commit is contained in:
parent
008248ee0f
commit
302da09248
2 changed files with 11 additions and 0 deletions
|
@ -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',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue