mirror of
https://github.com/elk-zone/elk.git
synced 2025-03-14 04:00:32 +03:00
include version in user-agent header
This commit is contained in:
parent
08262c8695
commit
ab1647763e
2 changed files with 6 additions and 3 deletions
|
@ -1,6 +1,6 @@
|
|||
import { stringifyQuery } from 'ufo'
|
||||
|
||||
import { APP_NAME } from '~/constants'
|
||||
import { defaultUserAgent } from '~/server/utils/shared'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
let { server, origin } = getRouterParams(event)
|
||||
|
@ -27,7 +27,7 @@ export default defineEventHandler(async (event) => {
|
|||
const result: any = await $fetch(`https://${server}/oauth/token`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'user-agent': APP_NAME,
|
||||
'user-agent': defaultUserAgent,
|
||||
},
|
||||
body: {
|
||||
client_id: app.client_id,
|
||||
|
|
|
@ -14,6 +14,7 @@ import { driver } from '#storage-config'
|
|||
|
||||
import type { AppInfo } from '~/types'
|
||||
import { APP_NAME } from '~/constants'
|
||||
import { version } from '~/config/env'
|
||||
|
||||
const storage = useStorage<AppInfo>()
|
||||
|
||||
|
@ -38,11 +39,13 @@ 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': APP_NAME,
|
||||
'user-agent': defaultUserAgent,
|
||||
},
|
||||
body: {
|
||||
client_name: APP_NAME + (env !== 'release' ? ` (${env})` : ''),
|
||||
|
|
Loading…
Add table
Reference in a new issue