Troubleshooting

Updated 8 July 2026

Common issues and their solutions. If you encounter problems, check this section first.

Common Issues

1. CORS Errors

Problem: CORS errors when accessing WooCommerce API

Solution:

/** @type {import('next').NextConfig} */
const nextConfig = {
  images: {
    remotePatterns: [
      {
        protocol: "https",
        hostname: "your-store.com",
      },
      {
        protocol: "https",
        hostname: "*.your-store.com", // For subdomains
      },
    ],
  },
};

export default nextConfig;

2. Cart Token Not Persisting

Problem: Cart items disappear on page refresh

Solution:

// In API route response
response.cookies.set("cart_token", cartToken, {
  httpOnly: true,
  sameSite: "lax",
  path: "/",
  secure: process.env.NODE_ENV === "production" // HTTPS only in production
});

3. Authentication Failures

Problem: Login not working or users getting logged out

Solution:

4. Product Images Not Loading

Problem: Images return 403 or don’t display // Images return 403 or don’t display with the given images return 403 or don’t display

Solution:

Add image domain to next.config.mjs:

images: { // Set images with the given images
  remotePatterns: [
    {
      protocol: "https",
      hostname: "your-store.com", // Set hostname with the given hostname
    },
    {
      protocol: "https",
      hostname: "*.your-store.com", // Set hostname with the given hostname
    },
  ],
}

Also check:

5. Build Errors

Problem: Build fails with module not found or other errors

Solution:

# Clear Next.js cache
rm -rf .next

# Remove node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

# Try building again
npm run build

6. API Rate Limiting

Problem: Too many requests to WooCommerce, getting rate limited

Solution:

7. Environment Variables Not Loading

Problem: Environment variables are undefined

Solution:

8. Middleware Not Working

Problem: Protected routes not redirecting to login

Solution:

9. Cart Not Updating

Problem: Cart operations not reflecting changes

Solution:

10. Slow Performance

Problem: Application is slow or unresponsive

Solution:

Debugging Tips

1. Check Network Tab

Inspect API requests and responses in browser DevTools:

2. Console Logs

Add logging in API routes and components:

// In API route
export async function GET(request) { // Get request with the given request
  console.log("API Request:", request.url); // Log API request with the given request url
  try {
    const data = await fetchData(); // Fetch data with the given fetch data
    console.log("API Response:", data); // Log API response with the given data
    return NextResponse.json(data);
  } catch (error) {
    console.error("API Error:", error); // Log API error with the given error
    return NextResponse.json({ error: error.message }, { status: 500 }); // Return next response with the given error message and status 500
  }
}

3. WooCommerce Logs

Check WooCommerce logs for backend errors:

4. Next.js Logs

Check terminal output during development:

5. Browser DevTools

Use browser DevTools for debugging:

Getting Help

If you’re still experiencing issues:

Common Error Messages

Prevention Tips

Tip: Most issues can be resolved by checking environment variables, restarting the dev server, and clearing browser cache.