Troubleshooting¶
Common issues and their solutions when working with NextPresser.
Connection Issues¶
Cannot Connect to WordPress¶
Problem: NextPresser cannot connect to your WordPress GraphQL endpoint.
Solutions:
1. Verify NEXT_PUBLIC_WORDPRESS_URL is correct
2. Check that WPGraphQL plugin is installed and activated
3. Verify CORS settings in WordPress
4. Check network connectivity
GraphQL Endpoint Not Found¶
Problem: Getting 404 errors when accessing /graphql.
Solutions: 1. Ensure WPGraphQL plugin is activated 2. Check permalink settings in WordPress 3. Verify the endpoint URL in your configuration
Authentication Issues¶
JWT Token Expired¶
Problem: Authentication tokens are expiring too quickly.
Solutions: 1. Increase token expiration time 2. Implement token refresh logic 3. Check token generation settings
Performance Issues¶
Slow Page Loads¶
Problem: Pages are loading slowly.
Solutions: 1. Enable ISR (Incremental Static Regeneration) 2. Implement proper caching 3. Optimize GraphQL queries 4. Use image optimization
Build Errors¶
TypeScript Errors¶
Problem: TypeScript compilation errors.
Solutions:
1. Run npm run type-check
2. Update type definitions
3. Check for missing dependencies
Logout Issues¶
Logout Functionality Not Working¶
Problem: The logout button is not fully working - users remain logged in after clicking logout.
Root Causes Identified:
- Missing Cookie Clearing: WordPress uses cookie-based authentication, and the logout function wasn't properly clearing all WordPress/WooCommerce session cookies
- WooCommerce Session Not Cleared: The WooCommerce session stored in localStorage (
woo-session) wasn't being cleared - Incomplete Cleanup Order: The cleanup steps weren't in the optimal order, and some steps might not complete before redirect
Fixes Applied:
1. Added Comprehensive Cookie Clearing¶
- Added
clearAllCookies()function that: - Identifies all cookies in the browser
- Clears WordPress-specific cookies (e.g.,
wordpress_logged_in_*,wordpress_*,wp_*) - Clears WooCommerce cookies (e.g.,
woocommerce_session_*,woocommerce_cart_*) - Attempts to clear cookies with multiple path/domain combinations to ensure they're removed
- Handles cookies with different security flags (secure, SameSite)
2. Proper Cleanup Sequence¶
The logout now follows this sequence:
1. Call logout mutation - Clears server-side session (if available)
2. Clear WooCommerce session - Removes woo-session and woocommerce-cart from localStorage
3. Clear all cookies - Removes all WordPress/WooCommerce cookies
4. Clear Apollo cache - Clears GraphQL cache and resets store
5. Clear all storage - Removes remaining localStorage and sessionStorage
6. Redirect - Redirects to home page with timestamp to prevent caching
3. Enhanced Error Handling¶
- Even if the logout mutation fails, all client-side cleanup still happens
- Comprehensive error handling ensures redirect always occurs
- Added delays to ensure cleanup completes before redirect
Backend Requirements:
- Logout Mutation Must Be Enabled
- The
logoutmutation must be available in your GraphQL schema -
This is typically provided by:
wp-graphql-corsplugin (recommended) - provides enhanced logout with cookie clearingwp-graphqlcore plugin - provides basic logout mutation
-
Enable Logout Mutation in wp-graphql-cors
- Go to WordPress Admin → GraphQL → Settings → CORS Settings
- Enable "Add logout mutation for destroying user session"
-
Ensure "Send site credentials" is also enabled
-
Cookie Settings
- Ensure cookies are set with proper domain/path
- If using cross-domain setup, ensure SameSite and Secure flags are configured correctly
Testing Checklist:
After deploying the fix, test the following:
- Click "Log out" button
- User is redirected to home page
- User cannot access
/accountpages (should redirect to login) - Browser DevTools → Application → Cookies shows no WordPress/WooCommerce cookies
- Browser DevTools → Application → Local Storage shows no
woo-sessionorwoocommerce-cart - Browser DevTools → Application → Session Storage is empty
- After logout, attempting to access account pages redirects to login
- No errors in browser console during logout
- User can log in again after logout
Troubleshooting Logout Issues:
- Check if logout mutation exists:
- Open browser DevTools → Network tab
- Click logout button
- Look for GraphQL request to
/graphql - Check if mutation is
logoutand if it returns success -
If mutation doesn't exist, enable it in wp-graphql-cors settings
-
Check cookies:
- Open DevTools → Application → Cookies
- Before logout, note all WordPress/WooCommerce cookies
- After logout, verify they're all gone
-
If cookies remain, check cookie domain/path settings
-
Check console logs:
- Open browser console
- Click logout
- Look for
[Auth]log messages - Should see: "Starting logout process", "Logout mutation successful", "Cookies cleared", etc.
-
If errors appear, note them for debugging
-
Verify Apollo cache is cleared:
- After logout, try accessing account page
- Should redirect to login immediately
- If it shows cached data, Apollo cache might not be clearing properly
Common Issues:
Issue: User can still access account pages after logout
- Cause: Cookies not being cleared properly
- Solution: Check cookie domain/path, ensure clearAllCookies() is working
Issue: Logout mutation fails - Cause: Mutation not enabled in wp-graphql-cors - Solution: Enable logout mutation in WordPress admin settings
Issue: User redirected but still logged in - Cause: Server-side session not cleared - Solution: Ensure logout mutation is working, check WordPress session handling
Getting Help¶
If you're still experiencing issues:
- Check the GitHub Issues
- Join our Discord Community
- Review the FAQ