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

Twitter embeds don't work on production #99

Closed
johncarter- opened this issue Jun 15, 2023 · 5 comments
Closed

Twitter embeds don't work on production #99

johncarter- opened this issue Jun 15, 2023 · 5 comments

Comments

@johncarter-
Copy link

Thanks for such a great package.

I am using Laravel, locally using Laravel Sail and in production using a Laravel Forge provisioned Digital Ocean droplet.

I am running this code:

Illuminate\Support\Facades\Artisan::command('embed', function () {
    $embera = new \Embera\Embera();

    // $testUrl = 'https://www.youtube.com/watch?v=J---aiyznGQ'; // 👌
    // $testUrl = 'https://vimeo.com/374131624'; // 👌
    // $testUrl = 'https://twitter.com/KYVENetwork/status/1655919857685221376?s=20'; // 💩
    $testUrl = 'https://twitter.com/Interior/status/507185938620219395'; // 💩

    $embedUrlData = $embera->getUrlData($testUrl);

    dump($embedUrlData);
});

It seems that Twitter embeds return an empty array every time on production, but work locally.

Does you have any suggestions why that could be?

Thanks again.

@johncarter-
Copy link
Author

Oh, mercy!

oscarotero/Embed#518 (comment)

@mpratt
Copy link
Owner

mpratt commented Jun 15, 2023

Hi @JohnCarter
Yes, Indeed there seems to be a problem with some hosting providers. I had a report coming from German servers having the same problem adn while doing the debug we found this instances where something similar happened:

https://twittercommunity.com/t/oembed-responses-are-returns-with-code-404/136813 (April 2020)
https://twittercommunity.com/t/oembed-404/167966 (März 2022)
https://twittercommunity.com/t/issue-with-twitter-oembed-api-when-accessed-from-digitalocean-droplets/194215 (May 2023)

Lets see if twitter responds

@mpratt
Copy link
Owner

mpratt commented Jun 21, 2023

There seems to be a solution to this problem:

Given the ip address ranges described here: https://developer.twitter.com/en/blog/product-news/2022/updated-source-ip-address-range

You need to allow all TCP connections from those IP ranges.

https://300m.com/security/twitter-oembed-broken-on-digitalocean/

Let me know if this works for you.

@johncarter-
Copy link
Author

I can confirm the following works:

  1. Go to Digital Ocean control panel > Networking > Firewalls (tab) > Create Firewall

  2. Add the following rules:
    image

  3. Assign that rule to your Droplet.

  4. Profit 💷

Thanks again for the package and prompt response, it's highly appreciated.

@mpratt
Copy link
Owner

mpratt commented Jul 4, 2023

No problem @johncarter- !
Thanks for the feedback, Im closing this issue. 👍

@mpratt mpratt closed this as completed Jul 4, 2023
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

2 participants