소스 검색

Avoid fetching prompts.json serverside

JuliusMoehring 1 년 전
부모
커밋
accb526cd6
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      app/store/prompt.ts

+ 7 - 2
app/store/prompt.ts

@@ -1,7 +1,7 @@
 import Fuse from "fuse.js";
-import { getLang } from "../locales";
-import { StoreKey } from "../constant";
 import { nanoid } from "nanoid";
+import { StoreKey } from "../constant";
+import { getLang } from "../locales";
 import { createPersistStore } from "../utils/store";
 
 export interface Prompt {
@@ -147,6 +147,11 @@ export const usePromptStore = createPersistStore(
     },
 
     onRehydrateStorage(state) {
+      // Skip store rehydration on server side
+      if (typeof window === "undefined") {
+        return;
+      }
+      
       const PROMPT_URL = "./prompts.json";
 
       type PromptList = Array<[string, string]>;