如何修复Facebook URL加载错误?Hybridauth库登录域名问题求助
Fixing "Can't load URL: The domain of this URL isn't included in the app's domains" for Hybridauth Facebook Login
Hey there! Let's work through this Facebook login error you're hitting with Hybridauth—this is a super common misconfiguration issue, so we'll get it sorted quickly. Here's what to check step by step:
1. Verify App Domains in Basic Settings
First, head to your Facebook App's Basic Settings (the first screenshot you mentioned):
- Locate the
App Domainsfield. You need to add every domain and subdomain your app uses here—without addinghttp://orhttps://prefixes. For example:- If your app runs on
example.com, addexample.com - If you have a subdomain like
app.example.com, add that too
- If your app runs on
- Make sure you don't include trailing slashes or port numbers (unless you're using a non-standard port for local development, like
localhostforlocalhost:8000)
2. Double-Check Valid OAuth Redirect URIs (Critical!)
This is the most often missed step. Go to Facebook Login > Settings in your app's product settings (your second screenshot):
- Find the
Valid OAuth Redirect URIsfield. You must paste the exact callback URL that Hybridauth uses to send users back to your app after Facebook authentication. - To find this URL:
- Check your Hybridauth configuration file (usually
config.phpor similar) for thecallbackparameter under the Facebook provider - Or, look at the full error URL in your browser—you'll see a
redirect_uriparameter that shows the exact URL Facebook is trying to use
- Check your Hybridauth configuration file (usually
- Ensure the URL includes the correct protocol (
http://orhttps://), full domain, and path (e.g.,https://yourdomain.com/hybridauth/facebook/callback) - Save these changes—this field is case-sensitive and must match perfectly
3. Confirm Site URL (For Web Apps)
Back in Basic Settings, check the Site URL field:
- This should be set to the root URL of your application, like
https://yourdomain.com/ - Facebook uses this to verify that your app's domains are legitimate, so it needs to be accurate
4. Clear Caches and Retest
After updating all settings:
- Click the Save Changes button in Facebook Developer Console (don't skip this!)
- Clear your browser's cache, or use an incognito/private window to test the login flow—old cached settings can sometimes prevent new changes from taking effect
- Also, double-check that your Hybridauth configuration for Facebook has the correct
redirect_uriset (if you're specifying it manually) to match what you entered in Facebook's settings
5. Local Development Notes (If Applicable)
If you're testing on localhost:
- Make sure your Facebook app is set to Development Mode (under App Status in Basic Settings)
- Add
localhostto App Domains, and your local callback URL (likehttp://localhost:8000/hybridauth/facebook/callback) to Valid OAuth Redirect URIs - Avoid using
127.0.0.1instead oflocalhostunless you explicitly add that domain too
Once you've gone through these steps, the error should disappear. Let me know if you run into any snags with the specific settings!
内容的提问来源于stack exchange,提问作者tariq ali




