Sites being redirected to site.com/posts/post-name/site.com/posts/post-name

I have a weird issue.

I’ve made my whole site, published it to an EC2 instance.
Everything works. You can see all the code on dans GitHub project.

When I post to Mastodon (via official Mac app) or LinkedIn I get a strange bug.
I type in oconnordaniel.com/posts/automation
When I click the link in those posts, it works fine.
When I click the generated previews on those site I get sent to https://www.oconnordaniel.com/posts/automation/oconnordaniel.com/posts/automation/

Two completely different sites. So I’m wondering if there’s something I need to change or if this should be reported to those sites.

Possibly the issue: the URL /posts/automation gets redirected to add the trailing slash, but it redirects via the insecure HTTP site. I imagine that might confuse link preview generators:

% curl -IL https://oconnordaniel.com/posts/automation

HTTP/2 301 
location: http://oconnordaniel.com/posts/automation/

HTTP/1.1 301 Moved Permanently
Location: https://oconnordaniel.com/posts/automation/

HTTP/2 200