Facebook login, Redirect Error 500

Hello,

I am trying to make facebook login works on my side: https://erp.domain.com

After login facebook, it shows me this error:

URL Blocked: This redirect failed because the redirect URI is not whitelisted in the app’s Client OAuth Settings. Make sure Client and Web OAuth Login are on and add all your app domains as Valid OAuth Redirect URIs.

After click on Okay, it redirects me to root site instead of the right side

https://erp.domain.com/api/method/frappe.www.login.login_via_facebook?error_code=1349168&error_message=URL+Blocked%3A+This+redirect+failed+because+the+redirect+URI+is+not+whitelisted+in+the+app’s+Client+OAuth+Settings.+Make+sure+Client+and+Web+OAuth+Login+are+on+and+add+all+your+app+domains+as+Valid+OAuth+Redirect+URIs.#_=_

Then, i try to change the domain to https://erp.domain.com/, it gives me following error:

    Traceback (most recent call last):
  File "/home/frapper/bench-repo/frappe-bench/apps/frappe/frappe/app.py", line 67, in application
    response = frappe.api.handle()
  File "/home/frapper/bench-repo/frappe-bench/apps/frappe/frappe/api.py", line 59, in handle
    return frappe.handler.handle()
  File "/home/frapper/bench-repo/frappe-bench/apps/frappe/frappe/handler.py", line 24, in handle
    data = execute_cmd(cmd)
  File "/home/frapper/bench-repo/frappe-bench/apps/frappe/frappe/handler.py", line 64, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frapper/bench-repo/frappe-bench/apps/frappe/frappe/__init__.py", line 1071, in call
    return fn(*args, **newargs)
TypeError: login_via_facebook() missing 2 required positional arguments: 'code' and 'state'

I already added domain “https://erp…domain.com” on facebook developer.

How could i solve this issue?
Thank you.

I just figure out the facebook link button is showing incorrect, it doesn’t contain “erp”, only

https://domain.com/

Any idea how to correct it.
Thank you.

i found a way to fix, adding my side into site_config.json
thank you.

Hi,
Can you explain the solution a little bit more elaborately?
What do you mean by my side?

Thanks

He probably meant site.
Not sure if this is the solution, but try adding hostname to your site config.