Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cors Error #106

Open
Ranjit1Das opened this issue Jan 9, 2022 · 11 comments
Open

Cors Error #106

Ranjit1Das opened this issue Jan 9, 2022 · 11 comments

Comments

@Ranjit1Das
Copy link

I am Using react messenger-customer-chat package in my react application, it throws cors policy errors in the production server(Google compute engine VM Server). The error is something like below...

Access to XMLHttpRequest at 'https://www.facebook.com/plugins/customer_chat/facade_gating/?page_id=110801524801659&suppress_http_code=1' from origin 'http://34.71.47.125' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any help or suggestion will be highly appreciated.

@tw0517tw
Copy link
Contributor

Have you whitelisted your domain in your Facebook app following the official doc (https://developers.facebook.com/docs/messenger-platform/discovery/facebook-chat-plugin/#whitelist-the-domain-of-your-website)?

@Ranjit1Das
Copy link
Author

Ranjit1Das commented Jan 11, 2022 via email

@raphaels17
Copy link

same here

@Rupal-Malik-au9
Copy link

🖐Hello everyone, I was also getting these error. I found that the pageId, I was using was wrong🤦‍♀️. These errors come only when your pageId is wrong or the domain is not whitelisted properly(I even tried with a ngrok url and it worked😵).

So the steps which I followed were-

1)In buisness.facebook.com go to inbox from sidebar and select chat plugin.[https://i.stack.imgur.com/rDk5d.png]

2)Click on setup to add your domain. [https://i.stack.imgur.com/exOi2.png]

3)Pick a setup method(standard for react/nextjs) and setup chat plugin(add language, domain , copy code and paste it) [https://i.stack.imgur.com/hDArZ.png]

4)You can add multiple domains[https://i.stack.imgur.com/zGdgx.png]

5)You will get pageId already embedded[https://i.stack.imgur.com/iRT13.png]

use this code and paste it in _document.js file in nextjs. and after deploying it will work perfectly. For any confusion please let me know. Thanks, Happy Coding ☺

@belkocik
Copy link

belkocik commented Feb 13, 2022

same here...
image
how to fix it? I followed this tutorial: https://www.youtube.com/watch?v=8e_4KIj4jBs

@Rupal-Malik-au9
Copy link

Rupal-Malik-au9 commented Feb 14, 2022

@bubuq3 I was also getting error with this library
instead of using this react-library
Login to business.facebook.com => go to inbox from sidebar and select chat plugin..[https://i.stack.imgur.com/rDk5d.png]
you will see a button for setup plugin there are 4 steps follow it and it will work. You will also get code to paste. Use that.

If you have any confusion, please check my previous message (I have added steps with Images)

@belkocik
Copy link

belkocik commented Feb 14, 2022

@Rupal-Malik-au9 Where am I supposed to copy this Messenger Chat Plugin Code in react/next.js app?
Ok, find some solutions: https://stackoverflow.com/questions/68463559/how-to-add-facebook-chat-messenger-to-next-js
what is yours?

@Rupal-Malik-au9
Copy link

Rupal-Malik-au9 commented Feb 17, 2022

@bubuq3 I pasted the code directly after body tag in _document.js

image

@Ranjit1Das
Copy link
Author

Ranjit1Das commented Feb 24, 2022 via email

@belkocik
Copy link

belkocik commented Mar 2, 2022

Have you solved your problem?If you still faced Cors error , I can help you. I faced a Cors error in one of my applications a month ago and I figured it out myself.

Would be nice if you share the solution here for all of us. Thank you! :)

@reefco
Copy link

reefco commented Mar 3, 2022

I had trouble with the same issue. Turns out you can't test it locally, even if you add your ip to the whitelisted domains. I was getting very frustrated with every answer being to just add your domain and check your ID! When I host my site locally, I get CORS errors and restricted access errors. I published my development website and whitelisted my development domain, and it worked right away. I believe it is because the plugin only supports HTTPS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants