Cloudflare Troubleshooting
Cloudflare's security features can sometimes interfere with Google OAuth authentication. This guide covers common issues and their solutions.
Common Cloudflare Issues
Overview
| Issue | Cloudflare Feature | Solution |
|---|---|---|
| CSRF token mismatch | Caching | Bypass rules |
| 403 on callback | WAF/Security Level | Allow rules |
| Bot fight blocking | Bot Fight Mode | Exception |
| Challenge loops | Security settings | Page rules |
| Slow authentication | Rocket Loader | Disable for GSI |
CSRF Token Mismatch
Symptoms
- "Invalid security token" error
- Authentication fails after Google consent
- Works without Cloudflare
Cause
Cloudflare caches the page including WordPress nonces, which then become invalid.
Solution
Option 1: Cache Bypass Rule
- Go to Cloudflare Dashboard > Rules > Page Rules
- Create new rule:
URL: yourdomain.com/wp-json/onetap/*
Setting: Cache Level
Value: Bypass - Save and Deploy
Option 2: Cache Rules (newer)
- Go to Rules > Cache Rules
- Create rule:
Expression: (starts_with(http.request.uri.path, "/wp-json/onetap"))
Cache status: Bypass cache
Additional URLs to Bypass
yourdomain.com/wp-json/*
yourdomain.com/wp-admin/admin-ajax.php
yourdomain.com/my-account/*
403 Forbidden on Callback
Symptoms
- Error 403 when Google redirects back
- "Access Denied" page
- Works fine without Cloudflare proxy
Cause
Cloudflare WAF or Security Level blocking the OAuth callback.
Solution
Option 1: WAF Exception
- Go to Security > WAF
- Click Tools
- Under IP Access Rules or custom rules
- Create exception for callback:
Expression: (http.request.uri.path eq "/wp-json/onetap/v1/callback")
Action: Skip all remaining custom rules
Option 2: Firewall Rule
- Go to Security > WAF > Custom Rules
- Create new rule:
Name: Allow OneTap Callback
Expression: (http.request.uri.path contains "/wp-json/onetap")
Action: Skip (select which features to skip)
Option 3: Lower Security for Path
Create a Page Rule:
URL: yourdomain.com/wp-json/onetap/*
Setting: Security Level
Value: Essentially Off
Bot Fight Mode Blocking
Symptoms
- One Tap or button doesn't work
- "Checking your browser" challenge appears
- Works in incognito or different browser
Cause
Cloudflare's Bot Fight Mode may flag Google's OAuth requests.
Solution
Option 1: Disable for OAuth paths
- Go to Security > Bots
- Find "Bot Fight Mode"
- Create exception rule:
Skip: (http.request.uri.path contains "onetap")
Option 2: Super Bot Fight Mode settings
If using Super Bot Fight Mode:
- Go to Security > Bots > Configure
- Under "Definitely automated":
- Consider "Managed Challenge" instead of "Block"
- Under "Verified bots":
- Ensure "Google" is allowed
Challenge Page Loops
Symptoms
- Stuck on "Checking your browser" page
- Page keeps reloading
- Never completes OAuth flow
Cause
Security challenge interrupts OAuth flow, preventing completion.
Solution
-
Create Page Rule for entire OAuth flow:
URL: yourdomain.com/wp-json/onetap/*
Security Level: Essentially Off -
Also consider for My Account page:
URL: yourdomain.com/my-account/*
Security Level: Low
Rocket Loader Issues
Symptoms
- Google button doesn't render
- "Cannot read properties of undefined" errors
- Button appears then disappears
Cause
Cloudflare Rocket Loader defers JavaScript, breaking Google Identity Services script initialization order.
Solution
Option 1: Disable Rocket Loader globally (simplest)
- Go to Speed > Optimization > Content Optimization
- Find "Rocket Loader"
- Toggle Off
Option 2: Exclude Google scripts
Add to your site's HTML or via plugin:
<script src="https://accounts.google.com/gsi/client" data-cfasync="false"></script>
Option 3: Worker to exclude
If using Cloudflare Workers, exclude GSI scripts from optimization.
Orange Cloud (Proxy) Issues
Symptoms
- Works with grey cloud (DNS only)
- Breaks with orange cloud (proxied)
Cause
Cloudflare proxy changes how requests are processed.
Diagnosis
- In Cloudflare DNS, toggle your domain from proxied (orange) to DNS only (grey)
- Wait 5 minutes
- Test Google sign-in
- If it works, issue is Cloudflare proxy-related
Solution
Rather than disabling proxy entirely:
- Keep proxy enabled for security
- Create exceptions for OAuth paths (see above)
- Ensure SSL mode is "Full (strict)"
SSL/TLS Configuration
Symptoms
- "Insecure connection" warnings
- Mixed content errors
- Redirect loops
Recommended Settings
- Go to SSL/TLS
- Set mode to Full (strict)
- Enable Always Use HTTPS
- Enable Automatic HTTPS Rewrites
Edge Certificates
Ensure you have:
- Valid edge certificate (Cloudflare provides free)
- Valid origin certificate (from your host or Let's Encrypt)
Complete Recommended Configuration
Page Rules (in order)
Rule 1: Bypass cache for WP JSON
URL: yourdomain.com/wp-json/*
Cache Level: Bypass
Security Level: Essentially Off
Rule 2: Bypass cache for My Account
URL: yourdomain.com/my-account/*
Cache Level: Bypass
Rule 3: Bypass cache for WP Admin
URL: yourdomain.com/wp-admin/*
Cache Level: Bypass
Cache Rules
Expression: (starts_with(http.request.uri.path, "/wp-json/"))
Action: Bypass cache
WAF Custom Rules
Name: Allow OneTap OAuth
Expression: (http.request.uri.path contains "onetap") or
(http.request.uri.path contains "wp-json/onetap")
Action: Skip (Super Bot Fight Mode, Security Level)
Speed Settings
- Rocket Loader: Off (or exclude GSI scripts)
- Auto Minify JS: Off for WordPress (or test carefully)
Debugging Cloudflare Issues
1. Check Ray ID
When you see an error:
- Note the Cloudflare Ray ID at bottom of error page
- Go to Security > Events
- Search by Ray ID
- See what rule triggered
2. Disable Features One by One
Test by temporarily disabling:
- Rocket Loader
- Bot Fight Mode
- Security Level (set to "Off" for testing)
- WAF Managed Rules
3. Development Mode
For temporary debugging:
- Go to Overview > Quick Actions
- Enable "Development Mode" (3 hours)
- This disables caching
- Test Google sign-in
4. Check Headers
Using browser dev tools:
- Network tab > select callback request
- Look for
cf-cache-statusheader - Should be
BYPASSorDYNAMICfor OAuth endpoints
Cloudflare Workers
If using Cloudflare Workers:
Don't Modify OAuth Requests
// In your worker, passthrough OAuth
addEventListener('fetch', event => {
const url = new URL(event.request.url);
// Don't modify OAuth endpoints
if (url.pathname.startsWith('/wp-json/onetap')) {
return event.respondWith(fetch(event.request));
}
// Your other worker logic...
});
APO (Automatic Platform Optimization)
If using Cloudflare APO for WordPress:
Symptoms with APO
- Cached nonces
- Stale authentication state
- Works for some users, not others
Solution
APO should automatically exclude:
- Logged-in users
- Dynamic URLs
But verify:
- Check APO settings include proper bypass rules
- Test as logged-out user in incognito
- May need custom cache bypass rules
Testing Your Configuration
Checklist
After configuration:
- Clear Cloudflare cache (Purge Everything)
- Clear browser cache
- Wait 5 minutes for propagation
- Test in incognito window
- Test on mobile device
- Check browser console for errors
- Verify callback URL works directly
Quick Test
# Test callback endpoint is reachable
curl -I "https://yourdomain.com/wp-json/onetap/v1/test"
# Should return 200, not 403
Getting Help
If issues persist:
- Cloudflare Support: For proxy/WAF issues
- OneTap Support: For plugin configuration
- Include:
- Ray ID from errors
- Screenshot of security events
- Current Cloudflare settings
Next Steps
- Security Plugins - Plugin-specific issues
- Common Issues - General troubleshooting
- Debug Mode - Enable logging