(continued from Self-hosting Supabase)
While setting up Supabase, I found a post by Christopher Mathews on Medium (How To Self-Host Supabase On Your Own Computer (Full Guide) | by Christopher Mathews | Medium) which addressed one of my main goals – to be able to connect to the dashboard and APIs through custom URLs on my wyethjones.com site. I had recently started using Cloudflare services for my main blog site, and this article described in detail how to create tunnels and setup security on the application. Great!
Tunnels and Policies
Following the instructions in the Medium article, I set up a few tunnels for key services and protected them with bypass policies using my IP address. I used the Docker method, which involved creating Docker containers on the host server which run as long as you need the tunnels. This also required setting up a CNAME record (proxied) for each endpoint in Cloudflare DNS. Everything worked, until I moved my laptop and plugged into a dock – suddenly I was getting 403 errors. I assumed that was due to my network changing- although the IP address was the same, I was joining from a ‘private network’ instead of a public network. By changing the public/private settings I was able to log in again. Eventually I also had to add some IPv6 addresses to ensure coverage from different machines. It was great to be able to connect to the Dashboard using https on a custom URL at my website.
Logs Error
As I explored the Supabase Dashboard, I did find an unfixed error in the Logs page. When trying to run queries, it would return 502 errors for every query. This turns out to be a known issue being tracked by the development team. API Gateway and postgresql logging not working for local development · Issue #26785 Not everything is my fault!
Connecting an Application
On my home development machine, I found and installed a Flutter chat app designed to work with Supabase (insideapp-srl/flutter_supabase_chat_core). After setting up my development environment with the Flutter SDK and other prerequisites, I ran their database prep scripts on my Supabase server, made some updates to pubspec.yaml, and modified the supabase_options.dart file with my anon key and Supabase self-hosted URL. Initially I picked Windows as the build target and ran a debug session, checking for any errors connecting to the Supabase backend. While it connected successfully, following the login steps in the app I got a 500 error – ‘AuthRetryableFetchException – Error sending confirmation mail‘ I updated my .env file for Supabase to set ENABLE_EMAIL_AUTOCONFIRM=true and once I relaunched the Docker containers, that seemed to fix it. After that, I also ran it against the Pixel Fold 35 and generic Android phone targets and they both worked. I was able to see the data from what I entered in the virtual devices land in the Postgres database managed by Supabase. Very cool to have a working app connected to my self-hosted Supabase.
Thanks to my search history I was able to recreate this from the last few days of experimentation. I left out a few of the rabbit holes I went down for sake of clarity. I don’t recommend the path I took unless you are really interested in learning about Docker containers, Linux storage, LogFlare and BigQuery, Postgres databases, and website tunnels. Thanks for reading! If you missed part 1, see here: (Self-hosting Supabase)
Comments