I am trying to use the Facebook JSSDK on a website to retrieve the pictures of the Facebook users when they log in to their account. I have used all the valid scopes required to get the user's images.The actual problem arises when I try to login from a different sub-domain. I get an error saying
JSSDK unknown host domain: The domain you are hosting the Facebook Javascript SDK is not in your app's Javascript SDK host domain list. Please specify your host domain in the App Dashboard login settings
Screenshot: JSSDK unknown host error
Here's the JS code I'm using to get the images for reference:
FB.api('/me?fields=albums.limit(5){name,count,cover_photo{picture},photos.limit(10){picture,images}}', function(response) {/*code*/});
I know it's telling me to add the new host domain to the list of allowed domains in Facebook App Dashboard and when I add that url there, it works fine. My actual problem is that the urls of my website are based on sub-domains and these sub-domains are variable, eg: abc.example.com, def.example.com, etc and its a long indefinite list of and its not possible for me to add all the existing subdomain variations manually in the dashboard as new subdomains are also being created. I am looking for a way by which I can use my Facebook functionality from any subdomain of my website or even a legit workaround of this restriction. Is there a way to add the new sub-domains through JS?
I even added the base url of my website(www.example.com) but that didn't worked. Then I tried adding a Wildcard url https://*.example.com in the host list but Facebook doesn't allow that.