Shout out to @hirvox@mastodon.online, @vidar@galaxybound.com, and @bearmine@masto.ai for the assist on solving my networking issue with Docker.

I’ll keep things short: React is a client side technology, which means that although it’s hosted inside of a Docker container, when it is called from a browser, the code runs within the browser, not at the server. This means that my attempts to call my API endpoints via Docker networking container name would never have worked since the call was coming from outside of the Docker network.

The solution was, sadly, to expose the API at a sub-domain, routing traffic to that container through Traefik’s domain name routing. I suppose in a way this is OK, as I was contemplating how I’d get the API available to other apps that I or someone in my Star Citizen org might want to make. This way, I have the API exposed for other apps to connect to. Of course, now I’m on the hook to ensure that the sensitive information is locked down with Express middleware (which I have in my actual implementation but turned off during development).

I will fully blame my 15+ years of C# development work for this brainfart. C# compiles down to a DLL which does run on the server, meaning that back-end communication is de rigueur.

As of right now, I have updated both the API and web test Dockerfiles and docker compose files so that the web site uses the public API URL, and the public API has been set up to use HTTPS. So not only do I have data flowing from database to API to website, but I got to remove that <meta> tag that let me call insecure content from a secure connection.

I suppose this means I have to stop screwing around and get back to actually working on the website.

1 Comment

  • Nimgimli

    November 27, 2022 - 9:32 AM

    Urk, please ignore comment on your other post! I should have caught up, THEN commented.

Sound off!

This site uses Akismet to reduce spam. Learn how your comment data is processed.