mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-24 00:42:51 +10:00
fix: $dropFetch SSR and rate limiting
This commit is contained in:
@@ -31,11 +31,16 @@ export const $dropFetch: DropFetch = async (request, opts) => {
|
|||||||
if (!getCurrentInstance()?.proxy) {
|
if (!getCurrentInstance()?.proxy) {
|
||||||
return (await $fetch(request, opts)) as any;
|
return (await $fetch(request, opts)) as any;
|
||||||
}
|
}
|
||||||
|
const id = request.toString();
|
||||||
|
|
||||||
|
const state = useState(id);
|
||||||
|
if (state.value) return state.value;
|
||||||
|
|
||||||
const headers = useRequestHeaders(["cookie"]);
|
const headers = useRequestHeaders(["cookie"]);
|
||||||
const { data, error } = await useFetch(request, {
|
const data = await $fetch(request, {
|
||||||
...opts,
|
...opts,
|
||||||
headers: { ...opts?.headers, ...headers },
|
headers: { ...opts?.headers, ...headers },
|
||||||
} as any);
|
} as any);
|
||||||
if (error.value) throw error.value;
|
state.value = data;
|
||||||
return data.value as any;
|
return data as any;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -28,12 +28,6 @@ export default defineNuxtConfig({
|
|||||||
"/signout": { prerender: true },
|
"/signout": { prerender: true },
|
||||||
|
|
||||||
"/api/**": { cors: true },
|
"/api/**": { cors: true },
|
||||||
|
|
||||||
"/api/v1/client/object/*": {
|
|
||||||
security: {
|
|
||||||
rateLimiter: false,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
nitro: {
|
nitro: {
|
||||||
@@ -80,5 +74,6 @@ export default defineNuxtConfig({
|
|||||||
},
|
},
|
||||||
strictTransportSecurity: false,
|
strictTransportSecurity: false,
|
||||||
},
|
},
|
||||||
|
rateLimiter: false
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -86,10 +86,6 @@ import {
|
|||||||
import { type Collection, type Game, type GameVersion } from "@prisma/client";
|
import { type Collection, type Game, type GameVersion } from "@prisma/client";
|
||||||
import { PlusIcon } from "@heroicons/vue/20/solid";
|
import { PlusIcon } from "@heroicons/vue/20/solid";
|
||||||
|
|
||||||
const gamesData = await $dropFetch<(Game & { versions: GameVersion[] })[]>(
|
|
||||||
"/api/v1/store/recent"
|
|
||||||
);
|
|
||||||
|
|
||||||
const collections = await useCollections();
|
const collections = await useCollections();
|
||||||
const collectionCreateOpen = ref(false);
|
const collectionCreateOpen = ref(false);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user