WordPress Connection Troubleshooter

Test your WordPress REST API connection and diagnose issues

Test Your WordPress API

Example: https://public-api.wordpress.com/wp/v2/sites/yoursite.wordpress.com

Common Issues & Solutions

1. Environment Variable Not Set in Vercel

Make sure you've added the WORDPRESS_API_URL environment variable in Vercel:

  1. Go to your Vercel project dashboard
  2. Click on Settings → Environment Variables
  3. Add: WORDPRESS_API_URL = https://yoursite.com/wp-json/wp/v2
  4. Click Save
  5. Redeploy your site

2. WordPress REST API Not Enabled

The WordPress REST API is enabled by default, but some plugins might disable it:

  • Check if you can access: https://yoursite.com/wp-json/wp/v2/posts in a browser
  • If you get a 404, the REST API might be disabled
  • Check your WordPress plugins for any that disable the REST API
  • Look for security plugins that might be blocking API access

3. CORS Issues

If the API works in the browser but not in your app:

  • Add this to your WordPress functions.php or use a plugin:
add_action('rest_api_init', function() {
  remove_filter('rest_pre_serve_request', 'rest_send_cors_headers');
  add_filter('rest_pre_serve_request', function($value) {
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
    header('Access-Control-Allow-Credentials: true');
    return $value;
  });
});

4. Using WordPress.com

If you're using WordPress.com, use this URL format:

https://public-api.wordpress.com/wp/v2/sites/yoursite.wordpress.com

5. No Posts Published

Make sure you have published posts in WordPress:

  • Posts must be Published (not Drafts)
  • Posts should have categories assigned
  • Check if posts are visible on your WordPress site