Implement Labrinth Canary API flag (#5531)
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
|
||||
let cachedRateLimitKey = undefined
|
||||
let rateLimitKeyPromise = undefined
|
||||
const LABRINTH_CANARY_COOKIE = 'labrinth-canary=always'
|
||||
|
||||
async function getRateLimitKey(config) {
|
||||
if (config.rateLimitKey) return config.rateLimitKey
|
||||
@@ -38,6 +39,15 @@ export const useBaseFetch = async (url, options = {}, skipAuth = false) => {
|
||||
options.headers['x-ratelimit-key'] = await getRateLimitKey(config)
|
||||
}
|
||||
|
||||
if (useFeatureFlags().value.labrinthApiCanary) {
|
||||
const existingCookie = options.headers.cookie
|
||||
if (!existingCookie?.split('; ').includes(LABRINTH_CANARY_COOKIE)) {
|
||||
options.headers.cookie = existingCookie
|
||||
? `${existingCookie}; ${LABRINTH_CANARY_COOKIE}`
|
||||
: LABRINTH_CANARY_COOKIE
|
||||
}
|
||||
}
|
||||
|
||||
if (!skipAuth) {
|
||||
const auth = await useAuth()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user