mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-06-22 04:11:32 +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) {
|
||||
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 { data, error } = await useFetch(request, {
|
||||
const data = await $fetch(request, {
|
||||
...opts,
|
||||
headers: { ...opts?.headers, ...headers },
|
||||
} as any);
|
||||
if (error.value) throw error.value;
|
||||
return data.value as any;
|
||||
state.value = data;
|
||||
return data as any;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user