From 39600a76464933d5678d37305ffec405b2806055 Mon Sep 17 00:00:00 2001 From: adueck Date: Sun, 29 Jan 2023 23:35:01 +0500 Subject: [PATCH] try different cors config --- account/src/index.ts | 15 ++++++++++----- account/src/lib/dictionary.ts | 4 ++++ 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/account/src/index.ts b/account/src/index.ts index 85303d4..7ee753f 100644 --- a/account/src/index.ts +++ b/account/src/index.ts @@ -18,10 +18,7 @@ app.use("/payment/webhook", express.raw({type: "*/*"})); app.use(express.json()); app.use(express.urlencoded({ extended: true })); app.use(express.static("public")); -app.use(cors({ - origin: inProd ? /\.lingdocs\.com$/ : "*", - credentials: true, -})); + if (inProd) app.set('trust proxy', 1); setupSession(app); app.use(passport.initialize()); @@ -29,12 +26,20 @@ app.use(passport.session()); setupPassport(passport); // Web Interface - returning html (mostly) +app.use(cors({ + origin: inProd ? /\.lingdocs\.com$/ : "*", + credentials: true, +})); app.use("/", authRouter(passport)); // REST API - returning json app.use("/api", apiRouter); app.use("/feedback", feedbackRouter); app.use("/payment", paymentRouter); - // Dictionary API +app.use(cors({ + origin: "*", // inProd ? /\.lingdocs\.com$/ : "*", + credentials: false, +})); +// Dictionary API app.use("/dictionary", dictionaryRouter) // START 💨 // diff --git a/account/src/lib/dictionary.ts b/account/src/lib/dictionary.ts index 88fb521..eeab9dc 100644 --- a/account/src/lib/dictionary.ts +++ b/account/src/lib/dictionary.ts @@ -54,6 +54,10 @@ export async function updateDictionary(): Promise<"no update" | "updated"> { collection?.clear(); lokidb.removeCollection(collectionName); collection?.insert(dictionary.entries); + const allWords = await fetchAllWords(); + allWordsCollection?.clear(); + lokidb.removeCollection(allWordsCollectionName); + allWordsCollection?.insert(allWords.words); return "updated"; }