@@ -14,7 +14,9 @@ import {
1414import type { Ref } from 'vue'
1515
1616import { useFeatureFlags } from '~/composables/featureFlags.ts'
17+ import { useVisitorUserAgent } from '~/composables/visitor-user-agent.ts'
1718import { withStagingArchonBaseUrl } from '~/helpers/archon.ts'
19+ import { getFrontendUserAgent , VISITOR_USER_AGENT_HEADER } from '~/helpers/user-agent.ts'
1820
1921async function getRateLimitKeyFromSecretsStore ( ) : Promise < string | undefined > {
2022 try {
@@ -33,10 +35,12 @@ export function createModrinthClient(
3335 apiBaseUrl : string
3436 archonBaseUrl : string
3537 sharedInstancesBaseUrl : string
38+ commitHash : string
3639 rateLimitKey ?: string
3740 } ,
3841) : NuxtModrinthClient {
3942 const flags = useFeatureFlags ( )
43+ const visitorUserAgent = useVisitorUserAgent ( )
4044 const optionalFeatures = [
4145 import . meta. dev ? ( new VerboseLoggingFeature ( ) as AbstractFeature ) : undefined ,
4246 ] . filter ( Boolean ) as AbstractFeature [ ]
@@ -46,6 +50,8 @@ export function createModrinthClient(
4650 archonBaseUrl : ( ) =>
4751 withStagingArchonBaseUrl ( config . archonBaseUrl , flags . value . archonApiStaging ) ,
4852 sharedInstancesBaseUrl : config . sharedInstancesBaseUrl ,
53+ userAgent : ( ) => ( import . meta. server ? getFrontendUserAgent ( config . commitHash ) : undefined ) ,
54+ headers : visitorUserAgent ? { [ VISITOR_USER_AGENT_HEADER ] : visitorUserAgent } : undefined ,
4955 archonSentryCapture : ( ) => flags . value . archonSentryCapture ,
5056 rateLimitKey : config . rateLimitKey || getRateLimitKeyFromSecretsStore ,
5157 features : [
0 commit comments