mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 09:04:55 +00:00
frontend deployment changes & stop prerendering (#7227)
* feat: frontend docker image * build: tweak gc, disable prerendering * feat: pass along UA * fix: fallback to process.env * build: remove this pr branch test * fix: don't pin docker image ver
This commit is contained in:
@@ -5,17 +5,10 @@ import {
|
||||
type NuxtClientConfig,
|
||||
NuxtModrinthClient,
|
||||
} from '@modrinth/api-client'
|
||||
import type { H3Event } from 'h3'
|
||||
import { getRequestHeader, type H3Event } from 'h3'
|
||||
|
||||
async function getRateLimitKeyFromSecretsStore(): Promise<string | undefined> {
|
||||
try {
|
||||
const mod = 'cloudflare:workers'
|
||||
const { env } = await import(/* @vite-ignore */ mod)
|
||||
return await env.RATE_LIMIT_IGNORE_KEY?.get()
|
||||
} catch {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
import { readEnv } from '~/helpers/env'
|
||||
import { getFrontendUserAgent, VISITOR_USER_AGENT_HEADER } from '~/helpers/user-agent'
|
||||
|
||||
export interface ServerModrinthClientOptions {
|
||||
event?: H3Event
|
||||
@@ -28,6 +21,10 @@ export function useServerModrinthClient(options?: ServerModrinthClientOptions):
|
||||
const sharedInstancesBaseUrl =
|
||||
config.sharedInstancesBaseUrl || config.public.sharedInstancesBaseUrl
|
||||
|
||||
const visitorUserAgent = options?.event
|
||||
? getRequestHeader(options.event, 'user-agent')
|
||||
: undefined
|
||||
|
||||
const features = []
|
||||
|
||||
if (options?.authToken) {
|
||||
@@ -42,7 +39,9 @@ export function useServerModrinthClient(options?: ServerModrinthClientOptions):
|
||||
const clientConfig: NuxtClientConfig = {
|
||||
labrinthBaseUrl: apiBaseUrl,
|
||||
sharedInstancesBaseUrl,
|
||||
rateLimitKey: config.rateLimitKey || getRateLimitKeyFromSecretsStore,
|
||||
userAgent: getFrontendUserAgent(config.public.hash),
|
||||
headers: visitorUserAgent ? { [VISITOR_USER_AGENT_HEADER]: visitorUserAgent } : undefined,
|
||||
rateLimitKey: config.rateLimitKey || (() => readEnv('RATE_LIMIT_IGNORE_KEY')),
|
||||
features,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user