Skip to content

Commit e595f14

Browse files
committed
Revert "Route docsearch to Vercel proxy and forward X-MS-USER-ID server-side"
This reverts commit c18bbce.
1 parent 04a51ce commit e595f14

File tree

3 files changed

+3
-63
lines changed

3 files changed

+3
-63
lines changed

docusaurus/api/meili-search.js

Lines changed: 0 additions & 49 deletions
This file was deleted.

docusaurus/docusaurus.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ const config = {
130130
],
131131
customFields: {
132132
meilisearch: {
133-
host: process.env.NEXT_PUBLIC_MEILI_HOST || 'https://ms-47f23e4f6fb9-30446.fra.meilisearch.io',
134-
apiKey: process.env.NEXT_PUBLIC_MEILI_API_KEY || '45326fd7e6278ec3fc83af7a5c20a2ab4261f8591bd186adf8bf8f962581622b',
133+
host: 'https://ms-47f23e4f6fb9-30446.fra.meilisearch.io',
134+
apiKey: '45326fd7e6278ec3fc83af7a5c20a2ab4261f8591bd186adf8bf8f962581622b',
135135
indexUid: 'strapi-docs',
136136
searchParams: {
137137
attributesToHighlight: null

docusaurus/src/theme/SearchBar/index.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ function SearchBarContent() {
3939
const uuid = (typeof crypto !== 'undefined' && crypto.randomUUID) ? crypto.randomUUID() : Math.random().toString(36).slice(2) + Date.now().toString(36);
4040
const value = JSON.stringify({ id: uuid, month: monthKey });
4141
window.localStorage.setItem(key, value);
42-
try {
43-
// Also set a same‑origin cookie so serverless proxy can read it
44-
const ttlDays = 45; // longer than a month for safety; we rotate monthly client‑side
45-
const maxAge = ttlDays * 24 * 60 * 60;
46-
document.cookie = `msUserId=${uuid}; Max-Age=${maxAge}; Path=/; SameSite=Lax` + (window.location.protocol === 'https:' ? '; Secure' : '');
47-
} catch {}
4842
return uuid;
4943
} catch (_) {
5044
return null;
@@ -164,12 +158,9 @@ function SearchBarContent() {
164158
import('meilisearch-docsearch'),
165159
import('meilisearch-docsearch/css')
166160
]).then(([{ docsearch }]) => {
167-
const meiliHost = siteConfig.customFields.meilisearch.host;
168-
// Use proxy on non-localhost to avoid CORS limits and inject server-side header
169-
const useProxy = typeof window !== 'undefined' && window.location && window.location.hostname !== 'localhost';
170161
const baseOptions = {
171162
container: searchButtonRef.current,
172-
host: useProxy ? `${window.location.origin}/api` : meiliHost,
163+
host: siteConfig.customFields.meilisearch.host,
173164
apiKey: siteConfig.customFields.meilisearch.apiKey,
174165
indexUid: siteConfig.customFields.meilisearch.indexUid,
175166

@@ -265,8 +256,6 @@ function SearchBarContent() {
265256

266257
const search = docsearch(baseOptions);
267258

268-
// If using proxy, docsearch will call `${origin}/api/indexes/<uid>/search`
269-
270259
searchInstanceRef.current = search;
271260
setIsLoaded(true);
272261

0 commit comments

Comments
 (0)