fix: Add WNW_CONFIG type definitions and fix TypeScript errors

This commit is contained in:
dwindown
2025-11-05 12:05:29 +07:00
parent af3ae9d1fb
commit 855f3fcae5
3 changed files with 34 additions and 6 deletions

View File

@@ -266,7 +266,7 @@ function Header({ onFullscreen, fullscreen, showToggle = true }: { onFullscreen:
const handleLogout = async () => {
try {
await fetch(window.WNW_CONFIG.restUrl + '/auth/logout', {
await fetch((window.WNW_CONFIG?.restUrl || '') + '/auth/logout', {
method: 'POST',
credentials: 'include',
});
@@ -465,7 +465,7 @@ function AuthWrapper() {
// In standalone mode, trust the initial PHP auth check
// PHP uses wp_signon which sets proper WordPress cookies
if (window.WNW_CONFIG?.standaloneMode) {
setIsAuthenticated(window.WNW_CONFIG.isAuthenticated);
setIsAuthenticated(window.WNW_CONFIG.isAuthenticated ?? false);
setIsChecking(false);
} else {
// In wp-admin mode, always authenticated