From 0e38b0eb5f02465c0faf6ff114a427ad3eaf2770 Mon Sep 17 00:00:00 2001 From: Dwindi Ramadhana Date: Sun, 4 Jan 2026 11:53:33 +0700 Subject: [PATCH] fix: Documentation API authentication and build script - Added X-WP-Nonce header to docs API fetch calls in Help page - Fixed build-production.sh to include docs/ folder (changed --exclude='*.md' to --exclude='/*.md') - This allows root-level docs like README.md to be excluded while keeping docs/ folder --- admin-spa/src/routes/Help/DocContent.tsx | 4 ++++ admin-spa/src/routes/Help/index.tsx | 4 ++++ build-production.sh | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/admin-spa/src/routes/Help/DocContent.tsx b/admin-spa/src/routes/Help/DocContent.tsx index 2fbe2df..628e2f8 100644 --- a/admin-spa/src/routes/Help/DocContent.tsx +++ b/admin-spa/src/routes/Help/DocContent.tsx @@ -21,8 +21,12 @@ export default function DocContent({ slug }: DocContentProps) { setError(null); try { + const nonce = (window as any).WNW_CONFIG?.nonce || (window as any).wpApiSettings?.nonce || ''; const response = await fetch(`/wp-json/woonoow/v1/docs/${slug}`, { credentials: 'include', + headers: { + 'X-WP-Nonce': nonce, + }, }); if (!response.ok) { diff --git a/admin-spa/src/routes/Help/index.tsx b/admin-spa/src/routes/Help/index.tsx index 0abf8e2..e5bbb39 100644 --- a/admin-spa/src/routes/Help/index.tsx +++ b/admin-spa/src/routes/Help/index.tsx @@ -27,8 +27,12 @@ export default function Help() { useEffect(() => { const fetchDocs = async () => { try { + const nonce = (window as any).WNW_CONFIG?.nonce || (window as any).wpApiSettings?.nonce || ''; const response = await fetch('/wp-json/woonoow/v1/docs', { credentials: 'include', + headers: { + 'X-WP-Nonce': nonce, + }, }); const data = await response.json(); diff --git a/build-production.sh b/build-production.sh index 12c1940..9b660b7 100755 --- a/build-production.sh +++ b/build-production.sh @@ -40,7 +40,7 @@ rsync -av --progress \ --exclude='admin-spa' \ --exclude='examples' \ --exclude='*.sh' \ - --exclude='*.md' \ + --exclude='/*.md' \ --exclude='archive' \ --exclude='test-*.php' \ --exclude='check-*.php' \