<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Dileesha Weliwaththa on Medium]]></title>
        <description><![CDATA[Stories by Dileesha Weliwaththa on Medium]]></description>
        <link>https://medium.com/@wdedweliwaththa?source=rss-dc7cc435c2bb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*5ayURZ1chHeTo0k-RLQi-A.jpeg</url>
            <title>Stories by Dileesha Weliwaththa on Medium</title>
            <link>https://medium.com/@wdedweliwaththa?source=rss-dc7cc435c2bb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:44:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@wdedweliwaththa/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Fix Visual Studio Code Explorer View Being Replaced by Folders View]]></title>
            <link>https://medium.com/@wdedweliwaththa/how-to-fix-visual-studio-code-explorer-view-being-replaced-by-folders-view-c07e86f5deb7?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c07e86f5deb7</guid>
            <category><![CDATA[vs-code-editor]]></category>
            <category><![CDATA[vscode-theme]]></category>
            <category><![CDATA[vscode]]></category>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 08:05:34 GMT</pubDate>
            <atom:updated>2025-12-31T08:05:34.342Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQQb3uTXtCt0TNc8RkO9sw.png" /></figure><h3>A Problem That’s Frustrating Developers</h3><p>If you’re a Visual Studio Code user, you may have encountered a frustrating issue: your familiar “<strong>Explorer” </strong>view suddenly gets replaced by the “<strong>Folders</strong>” view when opening a project. This disrupts your workflow and can be confusing, especially when you’re in the middle of an important coding session.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/429/1*ggXVxd6HZNXAHviIsYr1sg.png" /></figure><p>This common VS Code issue has been reported by developers across Stack Overflow and GitHub, and today, we’re going to solve it once and for all.</p><h3>Understanding the Issue</h3><p>Visual Studio Code’s interface is highly customizable, which is one of its greatest strengths. However, this flexibility can sometimes lead to unexpected behavior. The Explorer view, which shows your project files in a tree structure, may be replaced by alternative views like “<strong>Folders</strong>,” “<strong>Outline</strong>,” or “<strong>Timeline</strong>” due to:</p><ul><li>Accidental view rearrangement</li><li>Extension conflicts</li><li>Workspace settings overrides</li><li>View state corruption</li></ul><h3>Quick Fix: Reset View Locations Command</h3><p>The fastest solution is to use VS Code’s built-in command to reset all view locations:</p><h3>Step-by-Step Instructions</h3><ol><li><strong>Open the Command Palette</strong></li></ol><ul><li>Windows/Linux: Press Ctrl+Shift+P</li><li>Mac: Press Cmd+Shift+P</li></ul><p><strong>2. Type the command</strong>: View: Reset View Locations</p><ol><li><strong>Press Enter</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/351/1*YVLwwve0L_gWtsKnIsZ1vA.png" /></figure><p>That’s it! Your Explorer view should now be restored to its default position in the left sidebar.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c07e86f5deb7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving Azure MySQL Connection Issues with SSH Tunneling: A Developer’s Guide]]></title>
            <link>https://medium.com/@wdedweliwaththa/solving-azure-mysql-connection-issues-with-ssh-tunneling-a-developers-guide-420afc22cd63?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/420afc22cd63</guid>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Wed, 05 Nov 2025 08:25:10 GMT</pubDate>
            <atom:updated>2025-11-05T08:25:10.337Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Iol-MJOBAMYXaUyomv5lBA.png" /></figure><h3><strong>The Challenge</strong></h3><p>As developers working with cloud databases, we often encounter a frustrating workflow issue: <strong>dynamic IP addresses</strong>. Every time your home internet reconnects or you switch networks, your IP address changes. For Azure MySQL databases protected by firewall rules, this means:</p><ul><li><strong>Connection failures during development</strong></li><li><strong>Repeatedly updating Azure firewall allow lists</strong></li><li><strong>Wasted time managing network rules</strong></li><li><strong>Interrupted development workflow</strong></li></ul><p>After experiencing these issues firsthand, I discovered an elegant solution that completely eliminates this problem: <strong>SSH tunneling</strong>.</p><h4><strong>What is SSH Tunneling?</strong></h4><p>SSH tunneling (also known as SSH port forwarding) creates an encrypted connection between your local machine and a remote server, allowing you to securely access services through an intermediary server.</p><blockquote><strong>Think of it as a secure highway:</strong> instead of driving directly to your destination (the database), you drive through a trusted gateway that has permanent access.</blockquote><h4><strong>Flow</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*glgS132j3vvifPCRaDvQRA.png" /></figure><h3><strong>The Solution: Step-by-Step Implementation</strong></h3><h4><strong>Prerequisites</strong></h4><p>Before we begin, gather these details:</p><ul><li><strong>SSH private key file (`.pem` format)</strong></li><li><strong>SSH server with database network access</strong></li><li><strong>Azure MySQL connection credentials</strong></li></ul><h4><strong>Step 1: Create the SSH Tunnel</strong></h4><p>Open your terminal and run:</p><pre>ssh -i /path/to/your/keyfile.pem -L 3307:your-database.mysql.database.azure.com:3306 username@ssh-server-ip -N</pre><p><strong>Breaking down the command:</strong></p><ul><li><strong>(-i) </strong>Specifies your SSH private key</li><li><strong>(-L 3307)</strong> Creates local port forwarding from port 3307</li><li><strong>(:3306) </strong>Connects to MySQL’s standard port on the remote side</li><li><strong>(-N) </strong>Keeps the connection open without executing commands</li></ul><blockquote><strong>Why port 3307?</strong> <br>Port 3306 is often occupied by local MySQL installations. Using 3307 avoids conflicts.</blockquote><h4><strong>Step 2: Update Your Application Config</strong></h4><p>Modify your database configuration to connect through the tunnel:</p><pre>db:<br>  host: &#39;127.0.0.1&#39;      # Connect to localhost<br>  port: 3307             # Your local tunnel port<br>  database: &#39;your-database&#39;<br>  username: &#39;your-username&#39;<br>  password: &#39;your-password&#39;</pre><h4><strong>Step 3: Start Developing</strong></h4><p>That’s it! Your application now connects through the secure tunnel. Keep the tunnel terminal open while working.</p><h4><strong>Troubleshooting Common Issues</strong></h4><h4><strong>Issue 1: “Permission denied (publickey)”</strong></h4><p><em>SSH key not recognized or has incorrect permissions.</em></p><pre># Windows (PowerShell)<br>icacls &quot;path\to\keyfile.pem&quot; /inheritance:r<br>icacls &quot;path\to\keyfile.pem&quot; /grant:r &quot;%USERNAME%:R&quot;<br><br># macOS/Linux<br>chmod 600 path/to/keyfile.pem</pre><h4><strong>Issue 2: “Cannot listen to port: 3306”</strong></h4><p><em>Port already in use by local MySQL.</em></p><ul><li>Use a different local port (like 3307) as shown in the examples above.</li></ul><h4><strong>Issue 3: Connection Drops</strong></h4><p><em>Network interruption or timeout.</em></p><ul><li>Simply restart the SSH tunnel command.</li></ul><h3><strong>Optimizing Your Workflow</strong></h3><h4><strong>1. Create an NPM Script</strong></h4><p>Add this to your <strong><em>package.json</em></strong>:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;tunnel&quot;: &quot;ssh -i path/to/key.pem -L 3307:database.mysql.database.azure.com:3306 user@server -N&quot;,<br>    &quot;dev&quot;: &quot;npm run start:dev&quot;<br>  }<br>}</pre><p>Now start the tunnel with: <strong>npm run tunnel</strong></p><h4><strong>2. Use SSH Config for Convenience</strong></h4><p>Create ~<strong><em>/.ssh/config</em></strong></p><pre>Host db-tunnel<br>    HostName your-ssh-server-ip<br>    User your-username<br>    IdentityFile /path/to/keyfile.pem<br>    LocalForward 3307 database.mysql.database.azure.com:3306</pre><p>Then simply run: <strong>ssh db-tunnel -N</strong></p><h3><strong>Benefits: Before vs. After</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NXjACs4xN6GiWyxOoPQOdA.png" /></figure><h3><strong>Security Considerations</strong></h3><p>SSH tunneling actually <strong>improves</strong> security:</p><ul><li><strong>Encryption:</strong> All traffic is encrypted end-to-end</li><li><strong>Reduced Attack Surface:</strong> Only one server needs database access</li><li><strong>Key-Based Authentication:</strong> More secure than password authentication</li><li><strong>No Public Database Exposure:</strong> Database remains protected by firewall</li></ul><h3><strong>Real-World Impact</strong></h3><p>After implementing SSH tunneling in our development workflow:</p><ul><li><strong>Time Saved:</strong> Approximately 50 minutes per week previously spent managing firewall rules</li><li><strong>Productivity:</strong> Zero connection interruptions across different networks</li><li><strong>Security:</strong> Reduced attack surface from multiple IP allow lists to a single trusted server</li><li><strong>Developer Experience: </strong>Seamless database access from home, office, or remote locations</li></ul><h3><strong>Conclusion</strong></h3><p>SSH tunneling provides an effective solution to the dynamic IP address challenge in cloud database development. With a one-time setup, developers gain consistent database access while improving security posture.</p><blockquote><strong>Key Takeaway:</strong> Instead of constantly managing firewall rules, implement SSH tunneling for reliable, secure database connectivity regardless of your network location.</blockquote><h4><strong>Quick Reference</strong></h4><h4><strong>The Essential Command:</strong></h4><pre>ssh -i keyfile.pem -L 3307:database:3306 user@server -N</pre><h4><strong>The Essential Config:</strong></h4><pre>host: &#39;127.0.0.1&#39;<br>port: 3307</pre><blockquote><strong>Remember: Keep the tunnel running in one terminal, develop in another.</strong></blockquote><p><em>Have you faced similar challenges with cloud databases? Share your solutions in the comments below!</em></p><p>#azure #azuremysqlserver #ssh-tunnel #ssh #sshtunnel #mysql</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=420afc22cd63" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How to Migrate Metabase from H2 Database to Azure MySQL (with Docker)]]></title>
            <link>https://medium.com/@wdedweliwaththa/how-to-migrate-metabase-from-h2-database-to-azure-mysql-with-docker-e23d485beaab?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/e23d485beaab</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[metabase]]></category>
            <category><![CDATA[azure-mysql]]></category>
            <category><![CDATA[selfhost]]></category>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Wed, 30 Apr 2025 17:28:02 GMT</pubDate>
            <atom:updated>2025-04-30T17:28:02.608Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VVWjM7J4thbcFHQo" /></figure><p>Metabase is a powerful open-source BI tool, but running it on the default <strong>H2 database</strong> isn’t ideal for production. In this guide, I’ll walk you through how I safely migrated my Metabase instance from the embedded H2 database to <strong>Azure MySQL</strong>, including what went wrong — and how I fixed it.</p><h4>🚦 Why I Migrated from H2 to Azure MySQL</h4><ul><li><strong>H2 is great for quick testing</strong>, but not suitable for scaling or collaborative environments.</li><li><strong>Azure MySQL offers a more reliable, production-ready solution</strong> with managed backups, scalability, and performance features.</li><li>I also wanted to <strong>change the host</strong>, and the migration gave me the chance to test the setup on a different VM before moving into production</li></ul><h4>🧳 Step 1: Backing Up the Existing Metabase H2 Database</h4><p>Before doing anything risky, <strong>I created a full backup</strong> of the running Metabase container to avoid any data loss.</p><pre>docker cp metabase:/metabase.db ./</pre><p>If you’re transferring this database file to another VM, <strong>archive it</strong> for easier handling:</p><pre>tar -cvf metabase-db-backup.tar metabase.db</pre><p>This step is optional if you’re not moving between VMs, but it’s a safe backup habit.</p><p>To extract it later:</p><pre>tar -xvf metabase-db-backup.tar</pre><h4>🚚 Step 2: Moving the Backup to Another VM</h4><p>You can use different methods depending on your system:</p><p>From Linux to Linux (Using SCP)</p><pre>scp -i /root/dev_key.pem /root/metabase-db-backup.tar azureuser@6.75.25.78:/home/azureuser/</pre><p>From Windows (Using PSCP)</p><pre>pscp &quot;C:\Users\Lenovo\Documents\Keys\che_rt.pem&quot; root@195.77.257.9:/root/</pre><h4>🧩 Step 3: Migrating to Azure MySQL</h4><p>Now, it’s time to set up Metabase to use <strong>Azure MySQL as the application database</strong> instead of H2.</p><pre>export MB_DB_TYPE=mysql<br>export MB_DB_CONNECTION_URI=&quot;jdbc:mysql://duck.mysql.database.azure.com:3306/prod-metabase?user=admin_duck&amp;password=duckduck&quot;<br>java --add-opens java.base/java.nio=ALL-UNNAMED -jar metabase.jar load-from-h2 /home/azureuser/metabase.db </pre><p><strong>always use the metabase.db instead of directly accessing the mv.db<br></strong>If you willing to connect to postgres or any other DB check for the <a href="https://www.metabase.com/docs/latest/configuring-metabase/environment-variables"><strong>environment_variables</strong></a><strong> </strong>available also refer this <a href="https://www.metabase.com/docs/latest/installation-and-operation/migrating-from-h2"><strong>guide</strong></a><strong> </strong>if needed.</p><p><strong>But, there are some headaches…</strong></p><h4>⚠️ Common Error During Migration (And Fixes)</h4><p>I faced this frustrating error:</p><pre>Command failed with exception: ERROR Set up mysql target database and run migrations...: liquibase.exception.MigrationFailedException: Migration failed for change set migrations/000_migrations.yaml::89::camsaul:<br>     Reason: liquibase.exception.DatabaseException: (conn=345) Multiple primary key defined [Failed SQL: (1068) ALTER TABLE `metabase`**.`QRTZ_JOB_DETAILS` ADD PRIMARY KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`)]**</pre><p>Sometimes you might face these kind of errors aswell</p><pre>Migration failed<br>Multiple primary key defined<br>liquibase.exception.LiquibaseException: liquibase.exception.MigrationFailedException<br>Metabase Initialization FAILED</pre><p>After some digging, I found the culprit:</p><blockquote><em>Azure MySQL (8.0+) has a feature enabled by default:<br> </em><strong><em>sql_generate_invisible_primary_key = 1</em></strong></blockquote><p>This feature <strong>automatically adds invisible primary keys</strong>, which messes up Liquibase (used by Metabase for DB migrations).</p><h4>✅ Solution:</h4><ol><li>Go to <strong>Azure MySQL Flexible Server</strong></li><li>Navigate to: <strong>Server Parameters</strong></li><li>Search for sql_generate_invisible_primary_key</li><li><strong>Set it to 0 (off)</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AoNR4Bcfdj7ratbenVBKnQ.png" /><figcaption>Turn Off sql_generate_invisible_primary_key and Save it</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WUav4EQHDASqm_KIdpQyCQ.png" /><figcaption>After the Succesful Deployement</figcaption></figure><p>If Azure doesn’t allow you to turn it off, your best bet is to switch to another MySQL service — or even Postgres.</p><p><strong>More details: </strong><a href="https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_sql_generate_invisible_primary_key"><strong>MySQL Docs</strong></a></p><p>If all the Migrations goes well you’ll get this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*OvJ2d77yqonDHIwaDbLwLg.png" /><figcaption>If the Migrations Done Succesfully</figcaption></figure><h4>🐳 Step 4: Running Metabase with Azure MySQL Using Docker</h4><p>Once I resolved those errors and migrated properly, I launched a new Metabase container like this:</p><pre>docker rm &lt;old-container-id&gt;  # Remove old container, if running</pre><pre>docker run -d -p 3030:3000 \<br>  -e &quot;MB_DB_TYPE=mysql&quot; \<br>  -e &quot;MB_DB_DBNAME=prod-metabase&quot; \<br>  -e &quot;MB_DB_PORT=3306&quot; \<br>  -e &quot;MB_DB_USER=admin_user&quot; \<br>  -e &quot;MB_DB_PASS=your_password_here&quot; \<br>  -e &quot;MB_DB_HOST=your-azure-db-host.mysql.database.azure.com&quot; \<br>  --name metabase metabase/metabase</pre><h4>📝 Notes:</h4><p>Replace admin_user, your_password_here, and your-azure-db-host with your actual credentials.</p><p>Port 3030 is the one exposed on the host VM. Change it if needed.</p><pre>Command failed with exception: ERROR Set up mysql target database and run migrations...: liquibase.exception.MigrationFailedException: Migration failed for change set migrations/000_migrations.yaml::89::camsaul:<br>     Reason: liquibase.exception.DatabaseException: (conn=345) Multiple primary key defined [Failed SQL: (1068) ALTER TABLE `metabase`**.`QRTZ_JOB_DETAILS` ADD PRIMARY KEY (`SCHED_NAME`, `JOB_NAME`, `JOB_GROUP`)]**</pre><h3>🎉 Final Thoughts</h3><p>Migrating Metabase from H2 to Azure MySQL <strong>is totally doable</strong>, but there are a few gotchas to look out for — especially with newer MySQL server settings. By backing up first, testing on a dev VM, and carefully adjusting configurations, you can avoid downtime and ensure data safety.</p><h3>Key Takeaways:</h3><blockquote>Always backup your Metabase database before major changes.</blockquote><blockquote>Watch out for sql_generate_invisible_primary_key on MySQL 8.0+.</blockquote><blockquote>Use Docker for easy deployment and environment control.</blockquote><blockquote>Test your migration in a sandbox before moving to production.</blockquote><p>Have you faced similar issues with Metabase migrations or Azure MySQL? Share your experience in the comments or drop your questions — I’d love to help!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e23d485beaab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apple Sign In JWT Token Generator from p8 file: Simplify Your Authentication Process]]></title>
            <link>https://medium.com/@wdedweliwaththa/apple-sign-in-jwt-token-generator-from-p8-file-simplify-your-authentication-process-2ca0f9a1a613?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/2ca0f9a1a613</guid>
            <category><![CDATA[apple-authentication]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[apple]]></category>
            <category><![CDATA[setup-supabase]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Wed, 02 Apr 2025 17:21:29 GMT</pubDate>
            <atom:updated>2025-04-02T17:21:29.907Z</atom:updated>
            <content:encoded><![CDATA[<p>GITHUB Link — <a href="https://github.com/dileeshaweliwaththa/apple-p8-jwt-token-generator.git">https://github.com/dileeshaweliwaththa/apple-p8-jwt-token-generator.git</a></p><h3>What is the Apple Sign In JWT Token Generator?</h3><p>This Ruby tool simplifies the generation of JWT tokens required for Apple Sign In’s server-to-server authentication. With just a few configuration steps, you can create valid tokens with your .p8 file (Apple private key file).</p><h3>Features and Benefits</h3><ul><li><strong>Easy Configuration</strong>: Simple YAML-based setup</li><li><strong>Ruby-Based</strong>: Works with Ruby 2.5 or newer</li><li><strong>Customizable Validity</strong>: Set token expiration up to 180 days</li><li><strong>Automation-Ready</strong>: Can be integrated into your deployment pipeline</li><li><strong>Saves Development Time</strong>: No need to implement JWT logic for each project</li></ul><h3>Prerequisites</h3><p>Before getting started, ensure you have:</p><ul><li>Ruby 2.5 or newer installed</li><li>The JWT gem (gem install jwt)</li><li>Your Apple private key file (.p8)</li><li>Apple Developer credentials (Team ID, Services ID, Key ID)</li></ul><h3>Implementation Guide</h3><h3>Step 1: Installation</h3><p>Install the required gem:</p><pre>gem install jwt</pre><h3>Step 2: Configuration</h3><p>All settings are stored in config.yml:</p><ul><li>key_file: Path to your private key file (.p8)</li><li>team_id: Your Apple Developer Team ID</li><li>client_id: Your Services ID (also called Client ID)</li><li>key_id: The Key ID for your private key</li><li>validity_period: How long the token should be valid (in days, max 180)</li></ul><h3>Step 3: Generate Your Token</h3><p>Run the script:</p><pre>ruby generate_apple_token.rb</pre><p>The script will:</p><ol><li>Generate a JWT token</li><li>Display the token in the console</li><li>Save the token to current_token.txt</li></ol><h3>Detailed Running Instructions</h3><p>For those new to Ruby or this tool, you need to first install the ruby</p><ol><li><strong>Setup Environment</strong>:</li></ol><ul><li>Verify Ruby installation with ruby -v</li><li>Navigate to your application directory</li></ul><pre>cd &quot;path/to/application&quot;</pre><p><strong>2. Install Dependencies</strong>:</p><ul><li>Using the gem command:</li></ul><pre>gem install jwt</pre><h3>Troubleshooting Common Issues</h3><p>If you encounter problems:</p><ul><li>Verify your private key file path is correct</li><li>Check that all configuration values match your Apple Developer account</li><li>Ensure your private key hasn’t expired</li></ul><h3>Why Use This Tool?</h3><ol><li><strong>Simplicity</strong>: Clean, straightforward approach to token generation</li><li><strong>Reliability</strong>: Consistently formatted tokens that meet Apple’s requirements</li><li><strong>Time-Saving</strong>: Focus on building features instead of authentication mechanics</li><li><strong>Flexibility</strong>: Easy to integrate into your existing workflow</li></ol><h3>Getting Started Today</h3><p>With this tool, you can streamline your Apple Sign In implementation and focus on creating exceptional user experiences. The straightforward Ruby implementation makes it accessible for developers of all experience levels.</p><p><em>Keywords: Apple Sign In JWT, Ruby JWT generator, Apple authentication token, Apple private key, server-to-server authentication, supabase apple auth, .p8 jwt</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2ca0f9a1a613" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Ultimate Guide to Deploying Next.js]]></title>
            <link>https://medium.com/@wdedweliwaththa/the-ultimate-guide-to-deploying-next-js-a1501de3e4d0?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1501de3e4d0</guid>
            <category><![CDATA[azure-devops]]></category>
            <category><![CDATA[azure-app-service]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[nextjs]]></category>
            <category><![CDATA[nextjs-tutorial]]></category>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Sun, 15 Dec 2024 19:52:31 GMT</pubDate>
            <atom:updated>2024-12-15T19:52:31.566Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Ultimate Guide to Deploying Next.js Applications on Azure App Services with Environment Variables</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2_pUjch0VNuYXpIJ" /></figure><p>The deployment of a Next.js application to Azure Web App involves structured steps for proper setup, deployment, and management of environment variables.</p><p>This tutorial will go through the step-by-step process of deploying a <strong>Next.js application </strong>using<strong> Azure App Services </strong>along with<strong> GitHub Actions</strong>.</p><p>This Will be Done in 5Steps</p><ol><li><strong>Setting up the Next.js Application</strong></li><li><strong>Creating an Azure App Service</strong></li><li><strong>Configuring Environment Variables in GitHub and Azure</strong></li><li><strong>Setting up GitHub Actions for CI/CD</strong></li><li><strong>Testing the Deployment</strong></li></ol><h3><strong>1. Setting up the Next.js Application</strong></h3><p>Before deployment, ensure your Next.js app is ready for production:</p><p><strong>Create a Next.js App:</strong></p><pre>npx create-next-app@latest</pre><p><strong>Update </strong><strong>next.config.js for Azure</strong>: Configure the next.config.js file for standalone builds:</p><pre>/** @type {import(&#39;next&#39;).NextConfig} */<br>const nextConfig = {<br>  reactStrictMode: true,<br>  distDir: &#39;build&#39;,<br>  output: &#39;standalone&#39;,<br>  env: {<br>    CUSTOM_API_URL: process.env.CUSTOM_API_URL,<br>  },<br>};<br><br>module.exports = nextConfig;</pre><p><strong>Update </strong><strong>.env.local as required for the Environment Variables needed to use locally.</strong></p><pre>NEXT_PUBLIC_SUPABASE_URL=https://xxx.xxxxx.com<br>NEXT_PUBLIC_SUPABASE_ANON_KEY=eyXXXXXXXXXXXXXXX<br>NEXT_PUBLIC_API_URL=https://xxx.xxxxx.com</pre><p><strong>Test Locally</strong>: Run npm run dev to ensure the app works as expected locally. Then create a GitHub Repository and Push the Codebase</p><h3>2. Creating an Azure App Service</h3><p>Login to the Azure Portal: <a href="https://portal.azure.com/">Azure Portal</a></p><ul><li>Go to <strong>App Services</strong> &gt; <strong>Create</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/267/1*V_E4TL9fvOGfiuiXr5--3A.png" /><figcaption>Figure 2.1 — Web App or Static Web App?</figcaption></figure><ul><li>Go with the <strong>Web App</strong></li></ul><blockquote><strong>Why Choose Azure Web Apps over Static Web Apps for Next.js?</strong></blockquote><blockquote>Your choice between the two will come down to a case of what your app requirements are. Here are some serious advantages to using Azure Web Apps:</blockquote><blockquote><strong>1. Dynamic Content Support: </strong>As Azure Web Apps support the provision of server-side rendering alongside dynamic API endpoints they are well suited to frameworks such as Next.js.</blockquote><blockquote><strong>2. More Flexibility: </strong>Unlike Static Web Apps, that are optimized to serve static content, it is capable of handling dynamic back-end processing, authentications, and complex deployments.</blockquote><blockquote><strong>3. Seamless Integration with the CI/CD Pipelines: </strong>Automatically integrate Azure Web Apps with GitHub Actions to perform automated deployments.</blockquote><blockquote>For the Next.js apps that feature SSR or API routes, Azure Web Apps have even more better solutions available.</blockquote><p><strong>After Clicking the Web App you’ll get into this Screen</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/742/1*sa6KgibeIgRrGM_KdVdJ1w.png" /><figcaption>Figure 2.2 — For Runtime stack: Select the latest one currently Node 20 LTS the latest</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*GSIDGQmrGoPesSI4B-Aidw.png" /><figcaption>Figure 2.3— Select the Pricing Plans as per your Budget</figcaption></figure><blockquote>As per your Requirement you can configure Zone Redundancy and Other Services. For the Basic setup we don&#39;t need these.</blockquote><p>After that Click &gt; <strong>Review + Create</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*BiUhUK3CH0BKgSIOtHGNqA.png" /><figcaption>Figure 2.4 — Keep the other tab settings as it is.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6jxTaUnlBH5wtYrRLaSecg.png" /><figcaption>Figure 2.5 — Wait till Deployment is Completed</figcaption></figure><p>Then Go to the Created App Service &gt; <strong>Download Published Profile</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWMKptSh_n0bP5b6GZX-Nw.png" /><figcaption>Figure 2.6 — Basic Authentication Disabled</figcaption></figure><p>Here If the Basic Authentication is disabled.</p><p>Go to <strong>Settings</strong> &gt; <strong>Configurations</strong> and</p><ul><li>put node server.js as the startup command</li><li>Turn On the SCM and FTP Auth</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XXcTt1ER-jPWS-hg3_LcRg.png" /></figure><p>Then <strong>Download Published Profile</strong></p><h3>3. <strong>Configuring Environment Variables in GitHub and Azure</strong></h3><blockquote><strong>Note: </strong>Make Sure that You have the Admin Privileges in the Created Repository if not Settings will not be visible.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*eK1i5K1TD6fqGc0Dkl8KVA.png" /><figcaption>Figure 3.1 — Settings Visible only with Repository Admin Privileges</figcaption></figure><h4><strong>1. Add Secrets and Environment Variables to GitHub</strong>:</h4><h4><strong>To Add the Secret</strong></h4><ul><li>Go to your Created GitHub repository.</li><li>Navigate to <strong>Settings &gt; Secrets and variables &gt; Actions &gt; Secrets</strong>.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Xnher0nBTPbs96I_qcqWw.png" /><figcaption>Figure 3.2 — Actions secrets and variables</figcaption></figure><p><strong>Click &gt; Add New Repository Secret:</strong></p><ul><li>Use APP_PUBLISH_PROFILE as the Name.</li><li>For the Secret use the Content in the Previously Downloaded file from Azure. XXXXX.PublishSettings<strong> (Open this file in a Notepad and copy all the Content)</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cVant7D4Z9u-hWnb9nc-Xg.png" /><figcaption>Figure 3.3 — Adding Secrets</figcaption></figure><h4>To Add the Environment Variables</h4><ul><li>Navigate to <strong>Settings &gt; Secrets and variables &gt; Actions &gt; Variables</strong>.</li></ul><p><strong>Click &gt; Add New Repository Variable:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8Fytq-REMtXzbZ2o1821lw.png" /><figcaption>Figure 3.4 — Adding Variables</figcaption></figure><p>likewise Add all the Variables and Secrets needed for the Deployment.</p><h3>4. Setting up GitHub Actions for CI/CD</h3><p>From here We are going to Setup the GitHub Actions to Automate the Deployment Process.</p><h4><strong>Create a Workflow File</strong></h4><p>In your project, create a .github/workflows/next-deploy.yml file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*KRqHQ2NSrAWP2K2IbOgViw.png" /><figcaption>Figure 4.1 — Create the Workflow File</figcaption></figure><p>Paste this code into the workflow file and call the variables &amp; secrets in the env section properly.</p><pre>name: Build and deploy Next.js app to Azure Web App<br><br>on:<br>  push:<br>    branches:<br>      - main  <br>  workflow_dispatch:<br><br>env:<br>  APPLICATION_PUBLISH_PROFILE: ${{ secrets.APP_PUBLISH_PROFILE }}<br>  WEBAPP_NAME: &quot;CREATED_AZURE_WEB_APP_NAME&quot;<br><br>jobs:<br>  build:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - uses: actions/checkout@v4<br><br>      - name: Set up Node.js version<br>        uses: actions/setup-node@v4<br>        with:<br>          node-version: &quot;20.x&quot;<br><br>      - name: npm install, build, and test<br>        env:<br>            NEXT_PUBLIC_SUPABASE_URL: ${{ secrets.NEXT_PUBLIC_SUPABASE_URL }}<br>            NEXT_PUBLIC_SUPABASE_ANON_KEY: ${{ secrets.NEXT_PUBLIC_SUPABASE_ANON_KEY }}<br>            NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}<br><br>        run: |<br>          npm install<br>          npm run build<br>          mv ./build/static ./build/standalone/build<br>          mv ./public ./build/standalone<br><br>      - name: &quot;Deploy to Azure Web App&quot;<br>        id: deploy-to-webapp<br>        uses: azure/webapps-deploy@v3<br>        with:<br>          app-name: ${{ env.WEBAPP_NAME }}<br>          slot-name: &quot;Production&quot;<br>          publish-profile: ${{ env.APPLICATION_PUBLISH_PROFILE }}<br>          package: ./build/standalone</pre><p>Change the WEBAPP_NAME to Created Azure Web App Name</p><pre>WEBAPP_NAME: &quot;CREATED_AZURE_WEB_APP_NAME&quot;</pre><p>Now All Done</p><h3>5. Testing the Deployment</h3><p><strong>Trigger the Deployment</strong>:</p><p>Push your code to the main branch or trigger the workflow manually.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/786/1*nc-Q3B1C_YCffjDu-YOwGQ.png" /><figcaption>Figure 5.1 — Triggered Deployment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*uJcADFUEFsDXLQ-OLGhtlA.png" /><figcaption>Figure 5.2 — Successfully Deployed to the Azure Web Apps</figcaption></figure><p><strong>Validate the Deployment</strong>:</p><p>Navigate to your app’s default domain (https://&lt;your_app_name&gt;.azurewebsites.net). Ensure the app works as expected.</p><p><strong>Check Logs for Issues</strong>:</p><p>Use the <strong>Log Stream</strong> feature in Azure to debug issues if needed.</p><p>By following this step-by-step guide, I hope you should be able to deploy and manage a Next.js application on Azure Web App with a strong CI/CD pipeline and well-configured environment variables.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1501de3e4d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supabase Trigger Function To Delete and Soft Delete (Auth Users and Profiles)]]></title>
            <link>https://medium.com/@wdedweliwaththa/supabase-trigger-function-to-delete-and-soft-delete-auth-users-and-profiles-8d9908d1c6b3?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d9908d1c6b3</guid>
            <category><![CDATA[setup-supabase]]></category>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[flutter-supabase]]></category>
            <category><![CDATA[soft-delete]]></category>
            <category><![CDATA[database-triggers]]></category>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Fri, 13 Dec 2024 17:25:28 GMT</pubDate>
            <atom:updated>2024-12-13T17:25:28.414Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Dl5aQE5xOUEu3LZ6" /></figure><p>This article will describe how to configure triggers for the soft delete and hard delete operations through Supabase. The logic for deleting users is already available within the Supabase deleteUser() method; we will illustrate how to create the respective trigger functions that can maintain associated data consistency.</p><h4><strong>Step 1: Create the profiles Table</strong></h4><p>Lets begin by creating a profiles table with the following structure:</p><pre>CREATE TABLE public.profiles (<br>    id UUID PRIMARY KEY,<br>    email TEXT NOT NULL UNIQUE,<br>    deleted BOOLEAN DEFAULT FALSE,<br>    created_at TIMESTAMP DEFAULT NOW(),<br>    updated_at TIMESTAMP DEFAULT NOW()<br>);</pre><p>This can be made with a Foreign Key Relation with auth.user auth.user as per your requirement.</p><p><strong>deleted</strong>: Indicate to keep whether the profile is deleted or soft-deleted.</p><blockquote><strong>Note</strong>: Avoid using camelCase for column names like isDeleted in PostgreSQL. Stick to simple lowercase naming conventions such as isdeleted to prevent errors.</blockquote><h4><strong>Step 2: Implement the Soft Delete Trigger</strong></h4><p><strong>Function to Handle Soft Delete</strong></p><p>This function sets the deleted column to true in the profiles when the auth.users table&#39;s deleted_at column is updated from NULL to a timestamp.</p><pre>CREATE OR REPLACE FUNCTION public.handle_soft_deleted_user()<br>RETURNS TRIGGER<br>LANGUAGE plpgsql<br>SECURITY DEFINER<br>SET search_path = &#39;&#39;<br>AS $$<br>BEGIN<br>  IF OLD.deleted_at IS NULL AND NEW.deleted_at IS NOT NULL THEN<br>    UPDATE public.profiles<br>    SET deleted = TRUE,<br>        updated_at = NOW()<br>    WHERE id = NEW.id;<br>  END IF;<br><br>  RETURN NEW;<br>END;<br>$$;</pre><h4>Trigger for Soft Delete</h4><p>Attach the trigger to the auth.users table:</p><pre>CREATE TRIGGER on_auth_user_soft_deleted<br>AFTER UPDATE ON auth.users<br>FOR EACH ROW<br>WHEN (OLD.deleted_at IS NULL AND NEW.deleted_at IS NOT NULL)<br>EXECUTE FUNCTION public.handle_soft_deleted_user();</pre><blockquote><strong>Note</strong>: Here You Need to use <strong><em>SQL Editor</em></strong>in <strong><em>Supabase</em></strong> to create these Function and Trigger.</blockquote><h4><strong>Step 3: Add the Hard Delete Trigger</strong></h4><p>Function to Handle Hard Delete</p><p>This function deletes the corresponding profile upon a user’s deletion from the auth.users table.</p><pre>CREATE OR REPLACE FUNCTION public.handle_hard_deleted_user()<br>RETURNS TRIGGER<br>LANGUAGE plpgsql<br>SECURITY DEFINER<br>SET search_path = &#39;&#39;<br>AS $$<br>BEGIN<br>  DELETE FROM public.profiles<br>  WHERE id = OLD.id;<br><br>  RETURN OLD;<br>END;<br>$$;</pre><h4>Trigger for Hard Delete</h4><p>Attach the trigger to the auth.users table:</p><pre>CREATE TRIGGER on_auth_user_hard_deleted<br>AFTER DELETE ON auth.users<br>FOR EACH ROW<br>EXECUTE FUNCTION public.handle_hard_deleted_user();</pre><h4><strong>Step 4: Implement Supabase’s deleteUser() Method</strong></h4><p>Supabase offers a deleteUser() method that can support both soft delete and hard delete operations on the auth.users table. We will implement these triggers with this method.</p><p><strong>Delete a User</strong></p><p>This method takes the user’s ID and an optional parameter <strong>shouldSoftDelete</strong>. If <strong>shouldSoftDelete</strong>is <strong>true</strong>, the column <strong>deleted_at</strong>will be set to the current timestamp (soft delete). If <strong>false</strong>, the user will be deleted permanently (hard delete).</p><p><strong>Example Usage</strong></p><pre>const { data, error } = await supabase.auth.admin.deleteUser(<br>  &#39;715ed5db-f090-4b8c-a067-640ecee36aa0&#39;,<br>  { shouldSoftDelete: true } // or false for hard delete<br>);</pre><ul><li><strong>id</strong>: The user ID to delete.</li><li><strong>shouldSoftDelete</strong>: Boolean value indicating the type of delete.</li></ul><h4><strong>Conclusion</strong></h4><p>These trigger functions enable you to handle both soft and hard delete scenarios, while leveraging Supabase’s deleteUser() method.</p><p>This will maintain consistency between the auth.users and profiles tables while still using Supabase’s functionality to handle user deletion securely.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d9908d1c6b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Fix Supabase Realtime Service Restarting Issue in Self-Hosted Environments]]></title>
            <link>https://medium.com/@wdedweliwaththa/how-to-fix-supabase-realtime-service-restarting-issue-in-self-hosted-environments-788d2768588c?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/788d2768588c</guid>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Thu, 12 Sep 2024 19:13:16 GMT</pubDate>
            <atom:updated>2024-09-12T19:13:16.448Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*x5bwdbwHpsNwSCev" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7bT_6mwcMkuSny9LGX0xgw.png" /></figure><h3>Introduction</h3><p>While working with <strong>Supabase</strong> in a self-hosted environment, I encountered an issue where the <strong>Realtime</strong> service kept restarting repeatedly. This disrupted the backend functionality, leading to downtime for applications relying on real-time features. After researching and experimenting with different solutions, I managed to resolve the issue by fine-tuning the Docker Compose setup. Here’s a detailed walkthrough of the problem, the troubleshooting process, and the final solution.</p><h3>Problem</h3><p>I was running <strong>Supabase Realtime v2.30.34</strong> in a self-hosted environment with the following Docker container configuration:</p><pre>realtime-dev.supabase-realtime   supabase/realtime:v2.30.34    Restarting (1) 41 seconds ago</pre><p>The <strong>Supabase Realtime</strong> service was in a restart loop, and the logs showed an issue with the RLIMIT_NOFILE unbound variable. Below is a snippet of the logs:</p><pre>/app/run.sh: line 6: RLIMIT_NOFILE: unbound variable<br>+ ulimit -n<br>1048576</pre><p>This error indicated a problem with the <strong>file descriptor limits</strong> inside the Docker container, which was causing the service to fail to start.</p><blockquote><strong>NOTE : Use this to get the stat of the realtime service</strong></blockquote><pre>docker stats realtime-dev.supabase-realtime</pre><h3>Initial Attempt at a Solution</h3><p>I tried various approaches to resolve this, including:</p><ul><li>Setting <strong>ulimit</strong> in the <strong>Docker Compose</strong> configuration.</li><li>Modifying the environment variables to include <strong>RLIMIT_NOFILE</strong>.</li><li>Increasing <strong>healthcheck </strong>timeouts and intervals.</li><li>Explicitly setting <strong>ulimit </strong>in the Docker command.</li></ul><p>However, none of these solutions resolved the issue. The service continued to restart, and the logs continued to show the same error message.</p><h3>The Solution: Updating to the Latest Supabase Configuration</h3><p>After some more digging, I found the latest version of the <strong>Supabase</strong> Docker Compose file on their official <a href="https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml">GitHub repository</a>. The configuration included a more refined setup for the <strong>Realtime</strong> service, which ultimately resolved the issue.</p><p>Here’s the <strong>working Docker Compose configuration</strong>:</p><pre>realtime:<br>  # Container name for realtime<br>  container_name: realtime-dev.supabase-realtime<br>  image: supabase/realtime:v2.30.34<br>  depends_on:<br>    db:<br>      condition: service_healthy<br>    analytics:<br>      condition: service_healthy<br>  healthcheck:<br>    test: [ &quot;CMD&quot;, &quot;curl&quot;, &quot;-sSfL&quot;, &quot;--head&quot;, &quot;-o&quot;, &quot;/dev/null&quot;, &quot;-H&quot;, &quot;Authorization: Bearer ${ANON_KEY}&quot;, &quot;http://localhost:4000/api/tenants/realtime-dev/health&quot; ]<br>    timeout: 5s<br>    interval: 5s<br>    retries: 3<br>  restart: unless-stopped<br>  environment:<br>    PORT: 4000<br>    DB_HOST: ${POSTGRES_HOST}<br>    DB_PORT: ${POSTGRES_PORT}<br>    DB_USER: supabase_admin<br>    DB_PASSWORD: ${POSTGRES_PASSWORD}<br>    DB_NAME: ${POSTGRES_DB}<br>    DB_AFTER_CONNECT_QUERY: &#39;SET search_path TO _realtime&#39;<br>    DB_ENC_KEY: supabaserealtime<br>    API_JWT_SECRET: ${JWT_SECRET}<br>    SECRET_KEY_BASE: UpNVntn3cDxHJpq99YMc1T1AQgQpc8kfYTuRgBiYa15BLrx8etQoXz3gZv1/u2oq<br>    ERL_AFLAGS: -proto_dist inet_tcp<br>    DNS_NODES: &quot;&#39;&#39;&quot;<br>    RLIMIT_NOFILE: &quot;10000&quot;<br>    APP_NAME: realtime<br>    SEED_SELF_HOST: true</pre><p><a href="https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml">https://github.com/supabase/supabase/blob/master/docker/docker-compose.yml</a></p><h3>Key Changes</h3><p>Here’s what worked:</p><ul><li><strong>Setting </strong><strong>RLIMIT_NOFILE to a lower value</strong>: In the updated configuration, the RLIMIT_NOFILE was set to 10000, which is a more reasonable number of file descriptors for most systems. This change fixed the unbound variable issue and stabilized the service.</li><li><strong>Adding </strong><strong>SEED_SELF_HOST: true</strong>: This option ensures that the service is properly seeded when running in a self-hosted environment. It&#39;s essential for the initialization of the real-time functionality.</li><li><strong>Refining the healthcheck</strong>: The healthcheck parameters were adjusted to ensure the service is healthy before starting. The URL and timeout were set according to the most recent recommendations from Supabase.</li></ul><h3>Conclusion</h3><p>If you are self-hosting <strong>Supabase</strong> and encounter issues with the <strong>Realtime</strong> service restarting, I recommend referring to the latest Docker Compose configuration provided by the Supabase team. By adjusting the RLIMIT_NOFILE and ensuring proper environment variables, you can ensure the service runs smoothly.</p><p>For those who are maintaining a self-hosted Supabase instance, always stay updated with the official repository, as the configuration might evolve to include fixes for such issues.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=788d2768588c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ultimate Guide: Configuring the “Send SMS” Hook for Self-Hosted Supabase]]></title>
            <link>https://medium.com/@wdedweliwaththa/ultimate-guide-configuring-the-send-sms-hook-for-self-hosted-supabase-f32eb7ccce50?source=rss-dc7cc435c2bb------2</link>
            <guid isPermaLink="false">https://medium.com/p/f32eb7ccce50</guid>
            <dc:creator><![CDATA[Dileesha Weliwaththa]]></dc:creator>
            <pubDate>Wed, 04 Sep 2024 20:38:48 GMT</pubDate>
            <atom:updated>2024-09-04T20:38:48.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K6zt4i4i8q04NZpJJn32MA.png" /></figure><p>Looking to enhance your self-hosted Supabase setup with custom SMS integration? This comprehensive guide will walk you through the step-by-step process of configuring the <strong>“Send SMS”</strong> hook. Whether you aim to integrate a regional SMS provider, streamline OTP delivery for user authentication, or leverage alternate messaging channels, this tutorial covers everything you need to know.</p><p>This tutorial assumes you have <strong>already configured Edge Functions in your Supabase environment. </strong>If not, ensure your Edge Functions are set up before proceeding.</p><p>Follow these instructions to ensure smooth implementation and bypass common issues. Perfect for developers seeking flexibility and customization in their Supabase setup!</p><h3><strong>Introduction</strong></h3><p>The “Send SMS” hook allows using any custom SMS provider to send authentication messages such as one-time passcodes. While the official Supabase cloud service handles SMS out of the box, self-hosted setups require additional configuration. This tutorial will walk you through the process of configuring the necessary files and troubleshooting common pitfalls which may occur within a VM environment.</p><h3><strong>Step 1: Setup the docker-compose.yml File</strong></h3><p>The docker-compose.yml file is essential to set up your self-hosted Supabase instance as it defines the environment, and the services Docker should run.</p><p><strong>1.1 Locate the </strong><strong>docker-compose.yml File</strong></p><p>Navigate to the directory where Supabase is installed.</p><blockquote>supabase/docker/docker-compose.yml</blockquote><p>Open the docker-compose.yml file using any text editor.</p><p><strong>1.2 Add the Required Environment Variables</strong></p><p>In the environment section, add the following lines of configuration to enable the SMS hook:</p><pre>services:   <br>  auth:<br>    environment:<br>      GOTRUE_EXTERNAL_PHONE_ENABLED: &quot;true&quot;<br>      GOTRUE_HOOK_SEND_SMS_ENABLED: &quot;true&quot;<br>      GOTRUE_HOOK_SEND_SMS_URI: http://host.docker.internal:8000/functions/v1/send-sms<br>      GOTRUE_HOOK_SEND_SMS_SECRETS: v1,whsec_9hb8gJgYKAn2doIoujv52/wR7xE7XXYYZZPQRST=</pre><p><strong>Note:</strong> Ensure the actual values are wrapped in double quotes as demonstrated above.</p><p><strong>Swap the </strong><strong>GOTRUE_HOOK_SEND_SMS_SECRETS for your actual secret key which used in your </strong><strong>send-sms Edge Function.</strong></p><p><strong>1.3 Save the File</strong></p><p>With those lines added, save the file and quit out of the editor.</p><h3><strong>Step 2: Update the .env File</strong></h3><p><strong>(If you’ve already applied the configuration in the </strong><strong>docker-compose.yml file, You can skip this step.)<br></strong>So this approach helps keep your configurations organized and easy to manage. However, following this best practice enhances security and maintainability.</p><p>In the same directory where you found docker-compose.yml look for the .env and the following variables to both files.</p><p>.env</p><pre>GOTRUE_EXTERNAL_PHONE_ENABLED=true<br>GOTRUE_HOOK_SEND_SMS_ENABLED=true<br>GOTRUE_HOOK_SEND_SMS_URI=&quot;http://host.docker.internal:8000/functions/v1/send-sms&quot;<br>GOTRUE_HOOK_SEND_SMS_SECRETS=&quot;v1,whsec_9hb8gJgYKAn2doIoujv52/wR7xE7XXYYZZPQRST=&quot;</pre><p>docker-compose.yml</p><pre>services:   <br>  auth:<br>    environment:<br>      GOTRUE_EXTERNAL_PHONE_ENABLED: ${ENABLE_PHONE_SIGNUP}<br>      GOTRUE_HOOK_SEND_SMS_ENABLED: ${GOTRUE_HOOK_SEND_SMS_ENABLED}<br>      GOTRUE_HOOK_SEND_SMS_URI: ${GOTRUE_HOOK_SEND_SMS_URI}<br>      GOTRUE_HOOK_SEND_SMS_SECRETS: ${GOTRUE_HOOK_SEND_SMS_SECRETS}</pre><h3><strong>Step 3: Restart Supabase Services</strong></h3><p>You need to restart your instance of Supabase for the changes to take effect.</p><p><strong>3.1 Open Terminal</strong></p><p>Start your terminal or command line. You can now switch to your Supabase directory.</p><p><strong>3.2 Execute Restart Command</strong></p><p>Execute the following command to stop and restart your Supabase services:</p><pre>docker compose down <br><br>docker compose up -d</pre><p>This takes down the services and then boots them again with the updated configurations.</p><p><strong>Now that everything is set up, time to test if this SMS hook works locally.</strong></p><p>To trigger testing of the SMS hook, log in with any phone number on your self-hosted Supabase instance.</p><pre>const { data, error } = await supabase.auth.signInWithOtp({<br>  phone: &#39;+13334445555&#39;,<br>})</pre><p>This will fire an event for sending an SMS. Then it will Trigger the <strong>Edge Function</strong> That you have <strong>Created for the SMS Provider.</strong> If all goes well, that message will be sent using your custom SMS provider.</p><h3><strong>Step 4: Troubleshooting Common Issues</strong></h3><p><strong>4.1 Check Current Version</strong></p><p>Open your terminal and run the following in the terminal.</p><pre>docker ps</pre><p>It lists all of the containers running on your system; look for the <strong><em>supabase/gotrue</em></strong> service and verify the version number, which will be something like <strong><em>supabase/gotrue:v2.158.1</em></strong>. It needs to be this or Higher to work properly.</p><p><strong>Update Supabase Version (if needed)</strong></p><p><strong>4.2 Error: “AuthApiError: Unable to get SMS provider”</strong></p><p>To solve this error, follow the below steps:</p><p><strong>1. Check Environment Variables</strong> Carefully look at your environment variables from both docker-compose.yml and .env to ensure that all’s well.</p><p><strong>2. Check for Networking Issues (VM-Specific)</strong> If you’re running Supabase in a VM and the issue only occurs in this environment, replace host.docker.internal with the VM’s IP address.</p><h3><strong>Conclusion</strong></h3><p>Now, you have set up the “Send SMS” hook in your self-hosted Supabase instance by following this step-by-step guide. From now on, you can use any customized SMS provider for authentication, hence giving you great flexibility in your messaging system. You are good to go with seamless OTP delivery and other authentications since it is well configured for your environment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f32eb7ccce50" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>