<?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 Mark Munyaka on Medium]]></title>
        <description><![CDATA[Stories by Mark Munyaka on Medium]]></description>
        <link>https://medium.com/@markmunyaka?source=rss-8a038be42f1a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZbhY3tpe6HvXEMpD8Zxq9Q.png</url>
            <title>Stories by Mark Munyaka on Medium</title>
            <link>https://medium.com/@markmunyaka?source=rss-8a038be42f1a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 02:55:12 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@markmunyaka/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[OAuth 2.0 and JWT for securing APIs]]></title>
            <link>https://medium.com/@markmunyaka/oauth-2-0-and-jwt-for-securing-apis-dff77bb020a4?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff77bb020a4</guid>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[authentication]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 01:18:57 GMT</pubDate>
            <atom:updated>2026-11-17T01:18:57.171Z</atom:updated>
            <content:encoded><![CDATA[<p><a href="https://blog.jetbrains.com/kotlin/2026/07/secure-your-apis-oauth2-and-jwt-for-beginners/?utm_source=blog&amp;utm_medium=referral&amp;utm_campaign=influencer_distribution&amp;utm_content=kotlin_oauth2_jwt">Secure Your APIs: OAuth2 and JWT for Beginners ➚</a></p><p>The tutorial explains how OAuth2 and JSON Web Tokens (JWT) can be used to secure an API. Beginning with a primer on authentication and authorization, it walks through a working setup of a simple document management API, built with Spring and Kotlin and secured with OAuth2 and JWTs. The tutorial then moves on to advanced patterns and validations, where custom roles and permissions are needed. Developers who are familiar with Spring and Kotlin and want to get started with API security may find this useful. One key takeaway is that I should avoid hardcoding security decisions in my APIs, because doing so can introduce significant risks as the system grows.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff77bb020a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Go and the Web: Deploy to Railway]]></title>
            <link>https://medium.com/@markmunyaka/getting-started-with-go-and-the-web-deploy-to-railway-52bfb4ceaa62?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/52bfb4ceaa62</guid>
            <category><![CDATA[railways]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[cloud]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Mon, 30 Dec 2024 21:22:11 GMT</pubDate>
            <atom:updated>2024-12-30T21:22:11.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wH2s9SG_REOtkkQT.png" /></figure><p>This guide aims to show you how to build a web app using Go. You will create and test a simple web server built using Go on your local machine then deploy your web app to Railway.</p><p>Railway is a hosting service you can use to deploy your apps. It supports all sorts of deployment configs and has a plethora of features to customize the hosting set up for your app.</p><h3>Before We Start</h3><p>To follow along with the guide, you must have Go installed on your machine. Download and install Go here: <a href="https://github.com/Marktawa/falcon-feather/blob/master/doc">Download and Install Go</a>.</p><p>Git and the GitHub CLI should be installed on your machine. Download and install Git from here: <a href="https://git-scm.com/downloads">Downloads — Git</a>. Download and install the GitHub CLI from here: <a href="https://cli.github.com/">Download and Install GitHub CLI</a>.</p><p>A GitHub account and a Railway account are required. Sign up for GitHub here: <a href="https://github.com/join">Create GitHub account</a>. And sign up for Railway here: <a href="https://railway.com/login">Create Railway account</a></p><p>You must have some familiarity with HTML, CSS, JavaScript, HTTP to keep up with the concepts discussed in the guide.</p><p>Lastly, knowledge of Go is useful but not mandatory. This is a beginner guide.</p><h3>Hello, World! Go</h3><p>Open your work directory and create a new file and name it main.go.</p><p>Add the following code to main.go:</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br>  fmt.Println(&quot;Hello, World!&quot;)<br>}</pre><p>Save the file and test it by running the following command in your terminal in your working directory:</p><pre>go run main.go</pre><p>You should the text “Hello, World!” in your terminal output.</p><h3>Hello, World! Go on the Web</h3><p>We just created a simple CLI app using Go. Next, let’s create a simple web server using Go. Comment out the code you just wrote in the previous step. Above the comment block, add the following code:</p><pre>package main<br><br>import &quot;fmt&quot;<br>import &quot;net/http&quot;<br><br>func main() {<br>  http.HandleFunc(&quot;/&quot;, func(w http.ResponseWriter, r *http.Request) {<br>    fmt.Fprintf(w, &quot;&lt;h1&gt;Hello, World!&lt;/h1&gt;&quot;)<br>  })<br>  <br>  http.ListenAndServe(&quot;:80&quot;, nil)<br>}</pre><p>Save the file and run it. Visit localhost in your browser and you should see the text &quot;Hello, World!&quot; on a webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*vs4W7ihpDUETmSGK" /></figure><h3>Create and Upload GitHub Repo</h3><p>Initialize your project directory as a Git repo.</p><pre>git init</pre><p>Commit your project files. In this case it’s just the main.go file.</p><pre>git add main.go</pre><pre>git commit -m &quot;Initial commit&quot;</pre><p>Authenticate with GitHub</p><pre>gh auth login</pre><p>Upload your repo to GitHub</p><pre>gh repo create my-repo --public --source=. --remote=origin</pre><pre>git push --set-upstream origin master</pre><p>Replace my-repo with your desired repo name.</p><h3>Deploy to Railway</h3><p>Railway offers many ways to deploy your web app. You can use the dashboard, the CLI, the API etc. This article: <a href="https://docs.railway.com/quick-start">Railway Deployment Options</a> explains all the numerous ways you can deploy an app on the Railway platform.</p><p>We will use the dashboard for a start.</p><h3>Create a new Railway project</h3><p>Visit <a href="https://dev.new/">dev.new</a> in your browser. This will redirect you to <a href="https://railway.com/new">railway.com/new</a> and you will see a New Project modal with deployment options.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*qzEl7GfE-lahAMZ4" /></figure><p>Select Deploy from GitHub repo and choose the repo you created previously.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/0*3-yTiu3CkdXhCUGl" /></figure><p>The Railway platform will read the contents of your repo, initialize the project, build and then deploy it automatically as a service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*LHO7u5bD-_7X2p8Y" /></figure><h3>Generate a Domain for your project</h3><p>Select <strong>Settings</strong> inside your Railway project’s service. Under <strong>Networking</strong> click <strong>Generate Domain</strong>. This allows you to access your service on the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*SspEpVXbyfe8Hm-q" /></figure><p>Railway will generate a domain name for your app. The URL will appear a few seconds after clicking Generate Domain. You will use this URL to access your Go web app on the internet.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/603/0*BBgwyxGYtrcZ_tge" /></figure><p>Test out your newly generated domain name in your browser. You should see the text “Hello, World!” when you visit the link.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/0*tx1fpy-key57qsb_" /></figure><h3>Serve Static files using Go</h3><p>In your local project folder, create a new folder, static. Create a new file named index.html inside static and add the following code:</p><pre>&lt;body&gt;<br>  &lt;h1&gt;My Static Website&lt;/h1&gt;<br>&lt;/body&gt;</pre><h3>My Static Website</h3><p>Update the main.go file to serve static files from the static folder. Comment out all the code you have written. Above the comment block, add the following code to main.go:</p><pre>package main<br><br>import &quot;net/http&quot;<br><br>func main() {<br> http.Handle(&quot;/&quot;, http.FileServer(http.Dir(&quot;./static&quot;)))<br> http.ListenAndServe(&quot;:80&quot;, nil)<br>}</pre><p>Test your code:</p><pre>go run main.go</pre><p>Visit localhost in your browser and you should see a webpage with the text: &quot;My Static Website&quot;</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*2sUeAh_B8I5ddaVI" /></figure><h3>Update Deployment on Railway</h3><p>To update your deployment, simply stage and commit the file changes you have made using Git.</p><pre>git add .</pre><pre>git commit -m &quot;App update&quot;</pre><p>Then push the updates to GitHub.</p><pre>git push</pre><p>Railway will automatically update your project right after pushing your changes to GitHub. Wait a few seconds and visit your app URL to test your changes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*Yj5l1oh71OeTPh7g" /></figure><h3>Conclusion</h3><p>Congratulations! You have successfully built a simple web app using Go and deployed it to Railway. You learned how to create a basic web server, serve static files, and utilize GitHub for version control and deployment. Railway makes it easy to deploy and manage your applications with its user-friendly platform and powerful features. Keep experimenting with Go and Railway to build more complex and scalable web applications. Happy coding!</p><h3>References</h3><ol><li><a href="https://github.com/Marktawa/falcon-feather">GitHub Project Repo</a></li><li><a href="https://golang.org/dl/">Download and Install Go</a></li><li><a href="https://git-scm.com/downloads">Downloads — Git</a></li><li><a href="https://cli.github.com/">Download and Install GitHub CLI</a></li><li><a href="https://github.com/join">Create GitHub account</a></li><li><a href="https://railway.com/login">Create Railway account</a></li><li><a href="https://docs.railway.com/quick-start">Railway Deployment Options</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52bfb4ceaa62" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Started with Go and the Web: Hello, World!]]></title>
            <link>https://medium.com/@markmunyaka/getting-started-with-go-and-the-web-hello-world-20c570ba5916?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/20c570ba5916</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[https]]></category>
            <category><![CDATA[html]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Sun, 29 Dec 2024 03:06:48 GMT</pubDate>
            <atom:updated>2024-12-29T03:06:48.648Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UbcgmAKI3oBfa8fsUi90Bg.png" /></figure><p>Golang is growing in popularity as a server-side language. Developers use it as an alternative to more common technologies like PHP, Node.js, Ruby, Python, etc. One of the appeals of Go is its low resource usage. Developers on a budget can build powerful apps and host them cheaply on low-end infrastructure if they use Go.</p><p>This guide aims to gently introduce Go and see how it can be used to build applications for the web. This tutorial is aimed at beginners; however, experienced developers can also browse through it. You never know — you might learn a thing or two. Enough with the chit-chat, let’s get started.</p><h3>Prerequisites</h3><p>To follow along with the guide, you need to have Go installed on your machine. Download and install Go by following the instructions: <a href="https://go.dev/doc/install">Download and Install Go</a>.</p><p>Some knowledge of HTML is required for you to understand the concepts being illustrated. HTML is easy to catch on if you haven’t written it before. Follow this guide if you haven’t got a clue about HTML <a href="https://developer.mozilla.org/en-US/docs/Web/HTML">Learn HTML</a></p><p>Some knowledge of HTTP is required for you to understand the guide better. HTTP is the transport protocol for the web. Follow this guide to understand HTTP <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP">Learn HTTP</a></p><h3>Hello World, Go</h3><p>To get started with Go, open up your work folder and create a new file named main.go. Add the following code to main.go</p><pre>package main<br><br>import &quot;fmt&quot;<br><br>func main() {<br>    fmt.Println(&quot;Hello, World!&quot;)<br>}</pre><p>Save the file and open up a new terminal session in your work directory. Run the following command:</p><pre>go run main.go</pre><p>You should see the following output:</p><pre>Hello, World!</pre><p>Congratulations! You have created your first program using Go. Pause and absorb the nice feeling. :) Now back to work.</p><p>That was just a warm up to get things started.</p><h3>Hello World, Go on the Web</h3><p>It’s all well and good. We were able to print out “Hello, World!” on the terminal using Go, but that’s not the aim of this guide. The real aim is to print out “Hello, World!” on a webpage using Go. So how do we do it?</p><p>First off, comment out the code you just wrote in main.go. At the top of your comment block, give it a ubiquitous name like &quot;Step 1&quot;.</p><p>Above the comment block, add the following code:</p><pre>package main<br><br>import &quot;net/http&quot;<br>import &quot;fmt&quot;<br><br>func main() {<br>    http.HandleFunc(&quot;/&quot;, func(w http.ResponseWriter, r *http.Request){<br>        fmt.Fprintf(w, &quot;&lt;h1&gt;Hello, World!&lt;/h1&gt;&quot;)<br>    })<br>    http.ListenAndServe(&quot;:80&quot;, nil)<br>}</pre><p>Save the file and run it. Visit localhost in your browser and you should see the text &quot;Hello, World!&quot; on a webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*ITIrMUR6fwSn6dW5.png" /></figure><h3>Dynamic Hello</h3><p>Awesome! We just managed to create a web server using Go and print the text “Hello, World!”. The next step is to make the text change based on user input. Why? So that we understand the purpose of server side languages and how they can make our web pages dynamic.</p><p>Comment out the code you wrote in the previous step and at the top of the comment block give it a useful name like “Step 2”.</p><p>Above the comment block add the following code:</p><pre>package main<br><br>import &quot;fmt&quot;<br>import &quot;net/http&quot;<br><br>func main() {<br>    http.HandleFunc(&quot;/&quot;, func(w http.ResponseWriter, r *http.Request) {<br>        if r.FormValue(&quot;q&quot;) != &quot;&quot; {<br>            fmt.Fprintf(w, `<br>                &lt;body&gt;<br>                    &lt;h1&gt;Hello, %s&lt;/h1&gt;<br>                &lt;/body&gt;<br>            `, r.FormValue(&quot;q&quot;))<br>            return<br>        }<br>        fmt.Fprintf(w, `<br>            &lt;body&gt;<br>                &lt;form action=&quot;/&quot; method=&quot;GET&quot;&gt;<br>                    &lt;label&gt;Enter your name&lt;/label&gt;<br>                    &lt;input name=&quot;q&quot;&gt;<br>                    &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt;<br>                &lt;/form&gt;<br>            &lt;/body&gt;<br>        `)<br>    })<br>    http.ListenAndServe(&quot;:80&quot;, nil)<br>}</pre><p>Stop your server (CTRL + C). Save the file and run it. Visit localhost in your browser and you should see a form input with the label, &quot;Enter your name&quot; and a &quot;Submit&quot; button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/0*vRMmwOp_vBGok72R.png" /></figure><p>Enter your name and click on “Submit”. You should see the text “Hello, Jared”, if your name is “Jared”. Otherwise you will see the name you entered in the form.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/0*gpZnq-yRW33gIRa4.png" /></figure><h3>Counter</h3><p>Next, let’s try something a different. How about a counter?</p><p>Comment out the code you wrote in the previous step and at the top of the comment block give it a useful name like “Step 3”.</p><p>Above the comment block add the following code:</p><pre>package main<br><br>import &quot;fmt&quot;<br>import &quot;strconv&quot;<br>import &quot;net/http&quot;<br><br>func main() {<br>    http.HandleFunc(&quot;/&quot;, func(w http.ResponseWriter, r *http.Request) {<br>        if r.Method == &quot;POST&quot; {<br>            count, _ := strconv.Atoi(r.FormValue(&quot;counter&quot;))<br>            count++<br>           fmt.Fprintf(w, `<br>            &lt;body&gt;<br>                &lt;form action=&quot;/&quot; method=&quot;POST&quot;&gt;<br>                    &lt;label&gt;Counter&lt;/label&gt;<br>                    &lt;input name=&quot;counter&quot; value=&quot;%d&quot; readonly&gt;<br>                    &lt;button type=&quot;submit&quot;&gt;Add&lt;/button&gt;<br>                &lt;/form&gt;<br>                &lt;a href=&quot;/&quot;&gt;Reset&lt;/a&gt;<br>            &lt;/body&gt;<br>        `, count)<br>        return<br>        }<br>          fmt.Fprintf(w, `<br>            &lt;body&gt;<br>                &lt;form action=&quot;/&quot; method=&quot;POST&quot;&gt;<br>                    &lt;label&gt;Counter&lt;/label&gt;<br>                    &lt;input name=&quot;counter&quot; value=&quot;1&quot; readonly&gt;<br>                    &lt;button type=&quot;submit&quot;&gt;Add&lt;/button&gt;<br>                &lt;/form&gt;<br>            &lt;/body&gt;<br>            &lt;a href=&quot;/&quot;&gt;Reset&lt;/a&gt;<br>        `)<br>        })<br>    http.ListenAndServe(&quot;:80&quot;, nil)<br>}</pre><p>Save the file and run it. Visit localhost in your browser and you should see a form input with the number &quot;1&quot; inside, the label, &quot;Counter&quot;, and an &quot;Add&quot; button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/0*ku1nC8kshC4_sEYl.png" /></figure><p>Clicking the button should increase the value of the counter.</p><h3>Conclusion</h3><p>Congratulations! You’ve successfully built your first web application with Go, starting with a simple “Hello, World!” and progressing to a dynamic web page with user interaction. You’ve learned how to set up a basic web server, handle user input, and create a counter with Go. This is just the beginning — Go’s simplicity and efficiency make it a great choice for building scalable web applications.</p><p>As you continue exploring Go, you’ll find many more advanced features and libraries that can help you build powerful and efficient applications. Keep experimenting and building, and soon you’ll be mastering Go and creating complex web applications in no time. Happy coding!</p><p>Be on the look out for more tutorials. Ciao!</p><h3>Resources</h3><ul><li><a href="https://github.com/Marktawa/sturdy-train">GitHub Repo</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTML">Learn HTML</a></li><li><a href="https://developer.mozilla.org/en-US/docs/Web/HTTP">Learn HTTP</a></li><li><a href="https://go.dev/doc/">Learn Go</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20c570ba5916" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Before You Use That Framework…]]></title>
            <link>https://medium.com/@markmunyaka/before-you-use-that-framework-774c9f25f2fe?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/774c9f25f2fe</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Sun, 24 Nov 2024 11:55:06 GMT</pubDate>
            <atom:updated>2024-11-24T11:55:06.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JehaXVNs1d2dk8ky" /></figure><p>Pause and think. Do I really need it? What problems were frameworks meant to solve anyway? Time. Well, guess what? That is now solved, thanks to you know who (Sam Altman). So why would you still need to use a framework? It’s now an unnecessary dependency. Ditch it. Use a pure language. More control. You own every line of code you write. No more hacking your brain searching for stuff about obscure bugs. No more conforming to structures that are barely useful to your use case. Forget the hype. Detach yourself from trends and shiny things. Think. Think about your brain and what makes it easier.</p><p>Let’s take it even further. Some libraries are unneeded. Now with AI, you can make your own custom libraries that work exactly the way you intended. No funny workarounds. No hacky stuff. The best part? No need to read obscure docs or deal with bugs that come with most of these libraries. Just you and your code, exactly as you intended.</p><p>Extreme. Do you really need that programming language? Maybe all you need is C. After all, the OS is written in C. Make your own libraries and APIs that interface with your app’s frontend the way you intended. No handcuffs or unnecessary rules tying you down. Even better, you will benefit from nice little features like the portability of your app. Most of your codebase will work for various versions of your app, CLI, Desktop, Web, Mobile, etc., supporting all architectures and all OSes. Isn’t that a nice feeling? Knowing what you built can run anywhere on any machine (the promise that Java failed to deliver).</p><p>Better yet, do you even need the OS? Debatable. Can we make a case? Well, the OS comes with a lot of baggage, bugs, and unnecessary junk you won’t use. Why not instead make a custom OS tailored to your needs, that serves your app according to the way you designed it? No hacking your brain figuring out Linux commands. You are using your own. And these work for your use case. You become a better developer with a better sense of design. On the flip side, there are limitations. For starters, hardware is a black box. No such thing as an open-source CPU on the market. You will have to hum to the tune of AMD and Intel. No getting around this, unless… Unless you can hack your own CPU. Tsk tsk tsk. Good luck sinking the next three or so years of your life. This is the part where we have to stop. The hard limit of reality. The opportunity is there. AI has presented it. Who is ready to take it?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=774c9f25f2fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a PHP site on Railway]]></title>
            <link>https://medium.com/@markmunyaka/deploy-a-php-site-on-railway-b15bd8db5a5c?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b15bd8db5a5c</guid>
            <category><![CDATA[railways]]></category>
            <category><![CDATA[deploy]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[website]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Wed, 23 Oct 2024 00:12:28 GMT</pubDate>
            <atom:updated>2024-10-23T00:12:28.594Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KwirXHmwihc66k3qmmqxGw.png" /></figure><p>PHP is a framework for building websites. Railway is a platform for hosting web apps. Learn how to host a PHP site on Railway.</p><h3>Prerequisites</h3><ul><li>Railway Account</li><li>PHP</li></ul><h3>Create Home Page</h3><p>On your local machine, create a index.php file.</p><pre>&lt;h1&gt;Hello, World&lt;/h1&gt;</pre><p>Test your site.</p><pre>php -S localhost:8000</pre><h3>Deploy to Railway</h3><p>Install the Railway CLI tool:</p><pre>npm i -g @railway/cli</pre><p>Login to your Railway account:</p><pre>railway login --browserless</pre><p>Create a new Railway project:</p><pre>railway init</pre><p>Link your folder to your Railway project.</p><pre>railway link</pre><p>Deploy your app.</p><pre>railway up --detach</pre><p>When the site is ready, generate a domain.</p><pre>railway domain</pre><h3>Update Site and Redeploy</h3><p>Update home page, index.php:</p><pre>&lt;h1&gt;Hello World!&lt;/h1&gt;<br>&lt;p&gt;Happy to be here&lt;/p&gt;</pre><p>Test update locally:</p><pre>php -S localhost:8000</pre><p>Redeploy to Railway.</p><pre>railway up --detach</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b15bd8db5a5c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a Static Sveltekit site on Railway]]></title>
            <link>https://medium.com/@markmunyaka/deploy-a-static-sveltekit-site-on-railway-06b6405bb0a6?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/06b6405bb0a6</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[sveltekit]]></category>
            <category><![CDATA[webdev]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[railways]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 09:17:49 GMT</pubDate>
            <atom:updated>2024-10-22T09:17:49.752Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WCBvG_7iEePDrZbDLO4FZA.png" /></figure><p>Sveltekit is a framework for building websites. Railway is a platform for hosting web apps. This guide shows you how to host a static Sveltekit site on Railway.</p><h3>Prerequisites</h3><ul><li>Railway Account</li><li>Node.js</li></ul><h3>Create Sveltekit app</h3><p>On your local machine, create a package.json file in your app folder.</p><pre>{<br>    &quot;scripts&quot;: {<br>        &quot;dev&quot;: &quot;vite dev&quot;,<br>        &quot;build&quot;: &quot;vite build&quot;,<br>        &quot;preview&quot;: &quot;vite preview&quot;<br>    },<br>    &quot;devDependencies&quot;: {<br>        &quot;@sveltejs/adapter-static&quot;: &quot;latest&quot;,<br>        &quot;@sveltejs/kit&quot;: &quot;latest&quot;,<br>        &quot;@sveltejs/vite-plugin-svelte&quot;: &quot;latest&quot;,<br>        &quot;svelte&quot;: &quot;latest&quot;,<br>        &quot;vite&quot;: &quot;latest&quot;<br>    },<br>    &quot;type&quot;: &quot;module&quot;<br>}</pre><p>Install the dependencies.</p><pre>npm install</pre><p>Create a src/app.html file.</p><pre>&lt;head&gt;%sveltekit.head%&lt;/head&gt;<br>&lt;body&gt;%sveltekit.body%&lt;/body&gt;</pre><p>Create a src/routes/+page.svelte file.</p><pre>&lt;h1&gt;Hello, World!&lt;/h1&gt;</pre><p>Create a src/routes/+layout.js file.</p><pre>export const prerender = true;</pre><p>Create a svelte.config.js file:</p><pre>import adapter from &#39;@sveltejs/adapter-static&#39;;<br><br>/** @type {import(&#39;@sveltejs/kit&#39;).Config} */<br>const config = {<br>    kit: {<br>        adapter: adapter()<br>    }<br>};<br><br>export default config;</pre><p>Create a vite.config.js file:</p><pre>import { sveltekit } from &#39;@sveltejs/kit/vite&#39;;<br>import { defineConfig } from &#39;vite&#39;;<br><br>export default defineConfig({<br>    plugins: [sveltekit()]<br>});</pre><p>Run the development server.</p><pre>npm run dev</pre><p>Visit http://localhost:5173 to view your site.</p><h3>Build site</h3><pre>npm run build</pre><p>Sveltekit will produce a build folder containing your static site.</p><h3>Deploy to Railway</h3><p>Install the Railway CLI tool:</p><pre>npm i -g @railway/cli</pre><p>Login to your Railway account:</p><pre>railway login --browserless</pre><p>Create a new Railway project:</p><pre>railway init</pre><p>Link the build folder to your Railway project.</p><pre>cd build &amp;&amp; railway link</pre><p>Deploy your app.</p><pre>railway up --detach</pre><p>When the site is ready, generate a domain.</p><pre>railway domain</pre><h3>Update Site and Redeploy</h3><p>Update home page, src/routes/+page.svelte:</p><pre>&lt;h1&gt;Hello World!&lt;/h1&gt;<br>&lt;p&gt;Happy to be here&lt;/p&gt;</pre><p>Test update locally:</p><pre>npm run dev</pre><p>Rebuild site:</p><pre>npm run build</pre><p>Redeploy to Railway.</p><pre>railway up --detach</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06b6405bb0a6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a Static Nuxt site on Railway]]></title>
            <link>https://medium.com/@markmunyaka/deploy-a-static-nuxt-site-on-railway-55afeb753847?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/55afeb753847</guid>
            <category><![CDATA[nuxt]]></category>
            <category><![CDATA[railways]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 08:04:54 GMT</pubDate>
            <atom:updated>2024-10-21T08:04:54.967Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GcPeuHPJXmAZdaJUaq4LSg.png" /></figure><p>Nuxt is a framework for building websites. It is based on Vue.js, a frontend JavaScript library. Railway is a platform for hosting web apps. This guide shows you how to host a static Nuxt site on Railway.</p><h3>Prerequisites</h3><ul><li>GitHub Account</li><li>Railway Account</li><li>Node.js</li></ul><h3>Create Nuxt app</h3><p>On your local machine, create a new folder named my-app.</p><pre>mkdir my-app</pre><p>Open my-app.</p><pre>cd my-app</pre><p>Create a package.json file and add this:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;nuxt dev&quot;,<br>    &quot;generate&quot;: &quot;nuxt generate&quot;,<br>    &quot;preview&quot;: &quot;nuxt preview&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;nuxt&quot;: &quot;^3.13.2&quot;,<br>    &quot;vue&quot;: &quot;latest&quot;<br>  }<br>}</pre><p>Install the dependencies.</p><pre>npm install</pre><p>Create a app.vue file and add this:</p><pre>&lt;template&gt;<br>&lt;h1&gt;Hello, World!&lt;/h1&gt;<br>&lt;/template&gt;</pre><p>Run the development server.</p><pre>npm run dev</pre><p>Visit http://localhost:3000 to view your site.</p><pre>lynx localhost:3000</pre><h3>Build site</h3><p>Stop your server and build your Nuxt site.</p><pre>npm run generate</pre><p>Nuxt will produce a dist folder containing the static site that you&#39;ll deploy.</p><p>Preview your site.</p><pre>npm run preview</pre><h3>Deploy to Railway</h3><p>Install the Railway CLI tool:</p><pre>npm i -g @railway/cli</pre><p>Login to your Railway account:</p><pre>railway login --browserless</pre><p>Create a new Railway project:</p><pre>railway init</pre><p>Link the dist folder to your Railway project.</p><p>Change working directory to dist.</p><pre>cd dist</pre><p>Link current directory, i.e. dist to your Railway project.</p><pre>railway link</pre><p>Deploy your app.</p><pre>railway up --detach</pre><p>When site is ready, generate a domain and test your deployment.</p><pre>railway domain</pre><h3>Update Site and Redeploy</h3><p>Update home page, app.vue:</p><pre>&lt;template&gt;<br>&lt;h1&gt;Hello World!&lt;/h1&gt;<br>&lt;p&gt;Happy to be here&lt;/p&gt;<br>&lt;/template&gt;</pre><p>Test update locally:</p><pre>npm run dev</pre><p>Rebuild site:</p><pre>npm run generate</pre><p>Redeploy to Railway.</p><pre>cd dist &amp;&amp; railway up --detach</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55afeb753847" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy a Static Astro Site on Railway]]></title>
            <link>https://medium.com/@markmunyaka/deploying-a-static-astro-site-on-railway-84061722b032?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/84061722b032</guid>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Sun, 20 Oct 2024 06:50:50 GMT</pubDate>
            <atom:updated>2024-10-20T06:55:49.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tos5lj9znHQz-viGC-BCyA.png" /></figure><p>Astro is a framework for building websites. Railway is a platform for hosting web apps. This guide shows you how you can host an Astro website on Railway.</p><h3>Prerequisites</h3><ul><li>GitHub Account</li><li>Railway Account</li><li>Node.js</li></ul><h3>Create Astro app</h3><p>On your local machine, create a new folder named ‘my-app’.</p><pre>mkdir my-app</pre><p>Open `my-app`.</p><pre>cd my-app</pre><p>Create a package.json file and add the following:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;astro dev&quot;,<br>    &quot;start&quot;: &quot;astro dev&quot;,<br>    &quot;build&quot;: &quot;astro build&quot;,<br>    &quot;preview&quot;: &quot;astro preview&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;astro&quot;: &quot;^4.16.5&quot;<br>  }<br>}</pre><p>Install the dependencies.</p><pre>npm install</pre><p>Create a src/pages folder and add a src/pages/index.astro file.</p><pre>mkdir -p src/pages &amp;&amp; touch src/pages/index.astro</pre><p>Add this to src/pages/index.astro</p><pre>&lt;h1&gt;Hello, World!&lt;/h1&gt;</pre><p>Run the development server.</p><pre>npm run dev</pre><p>Visit http://localhost:4321 to view your site.</p><pre>lynx localhost:4321</pre><h3>Build Site</h3><p>Stop your server and build your Astro site:</p><pre>npm run build</pre><p>Astro will produce a dist folder containing the static site you will deploy.</p><p>Preview your build:</p><pre>npm run preview</pre><h3>Deploy to Railway</h3><p>Install the Railway CLI tool:</p><pre>npm i -g @railway/cli</pre><p>Login to your Railway account:</p><pre>railway login --browserless</pre><p>Create a new Railway project:</p><pre>railway init</pre><p>Link the dist folder to your Railway project.</p><p>Change working directory to dist.</p><pre>cd dist</pre><p>Link current directory, i.e. dist to your Railway project.</p><pre>railway link</pre><p>Deploy your app.</p><pre>railway up --detach</pre><p>When site is ready, generate a domain.</p><pre>railway domain</pre><h3>Test Deployment</h3><pre>lynx &lt;YOUR-APP-DOMAIN&gt;</pre><h3>Update Site and Redeploy</h3><p>Update home page, src/pages/index.astro:</p><pre>&lt;h1&gt;Hello World!&lt;/h1&gt;<br>&lt;p&gt;Happy to be here&lt;/p&gt;</pre><p>Test update locally:</p><pre>npm run dev</pre><p>Rebuild site:</p><pre>npm run build</pre><p>Redeploy to Railway.</p><pre>cd dist &amp;&amp; railway up --detach</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=84061722b032" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying a Static Next.js Site to Railway]]></title>
            <link>https://medium.com/@markmunyaka/deploying-a-static-next-js-site-to-railway-459d748b1d12?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/459d748b1d12</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[railways]]></category>
            <category><![CDATA[nextjs]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Sat, 19 Oct 2024 01:55:49 GMT</pubDate>
            <atom:updated>2024-10-19T01:55:49.220Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dGBJb99xAHLmFDIbbCte1w.png" /></figure><p>Next.js is a React framework for building web apps. Railway is a platform for hosting web apps. This guide shows you how to host a static Next site on Railway.</p><h3>Prerequisites</h3><ul><li>GitHub Account</li><li>Railway Account</li><li>Node.js</li></ul><h3>Create Next app</h3><p>In your local machine, create a new folder named my-app.</p><pre>mkdir my-app</pre><p>Install react, react-dom, and next as npm dependencies.</p><pre>npm install next@latest react@latest react-dom@latest</pre><p>Open your package.json file and add the following npm scripts:</p><pre>{<br>  &quot;scripts&quot;: {<br>    &quot;dev&quot;: &quot;next dev&quot;,<br>    &quot;build&quot;: &quot;next build&quot;,<br>    &quot;start&quot;: &quot;next start&quot;,<br>    &quot;lint&quot;: &quot;next lint&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;next&quot;: &quot;^14.2.15&quot;,<br>    &quot;react&quot;: &quot;^18.3.1&quot;,<br>    &quot;react-dom&quot;: &quot;^18.3.1&quot;<br>  }<br>}</pre><p>Create an app folder, then add a layout.tsx and page.tsx file.</p><pre>mkdir app &amp;&amp; touch app/layout.tsx app/page.tsx</pre><p>Create root layout inside app/layout.tsx:</p><pre>export default function RootLayout({<br>  children,<br>}: {<br>  children: React.ReactNode<br>}) {<br>  return (<br>    &lt;html lang=&quot;en&quot;&gt;<br>      &lt;body&gt;{children}&lt;/body&gt;<br>    &lt;/html&gt;<br>  )<br>}</pre><p>Create home page, app/page.tsx:</p><pre>export default function Page() {<br>  return &lt;h1&gt;Hello World!&lt;/h1&gt;<br>}</pre><p>Run the development server.</p><pre>npm run dev</pre><p>Visit http://localhost:3000 to view your site.</p><pre>lynx localhost:3000</pre><h3>Build Next App</h3><p>Stop your server by pressing CTRL plus C on your keyboard.</p><p>Add a static export configuration to your Next.js app. Create a next.config.js file:</p><pre>touch next.config.js</pre><p>Add this to next.config.js:</p><pre>/**<br> * @type {import(&#39;next&#39;).NextConfig}<br> */<br>const nextConfig = {<br>  output: &#39;export&#39;,<br>}<br><br>module.exports = nextConfig</pre><p>Build your application:</p><pre>npm run build</pre><p>Next.js will produce an out folder which contains the HTML/CSS/JS assets for your application.</p><h3>Deploy to Railway</h3><p>Install the Railway CLI tool:</p><pre>npm i -g @railway/cli</pre><p>Login to your Railway account:</p><pre>railway login --browserless</pre><p>Create a new Railway project:</p><pre>railway init</pre><p>Link the out folder to your Railway project.</p><p>Change working directory to out.</p><pre>cd out</pre><p>Link current directory, i.e. out to your Railway project.</p><pre>railway link</pre><p>Deploy your app.</p><pre>railway up --detach</pre><p>When the site is ready, generate a domain.</p><pre>railway domain</pre><h3>Test Deployment</h3><pre>lynx &lt;YOUR-APP-DOMAIN&gt;</pre><h3>Update Site and Redeploy</h3><p>Update home page, app/page.tsx:</p><pre>export default function Page() {<br>  return (<br>    &lt;main&gt;<br>      &lt;h1&gt;Hello World!&lt;/h1&gt;<br>      &lt;p&gt;Happy to be here&lt;/p&gt;<br>    &lt;/main&gt;<br>  )<br>}</pre><p>Test update locally:</p><pre>cd .. &amp;&amp; npm run dev</pre><p>Rebuild site:</p><pre>npm run build</pre><p>Redeploy to Railway.</p><pre>cd out &amp;&amp; railway up --detach</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=459d748b1d12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build and Deploy Medusa: Using Railway, Cloudflare, and NeonDB]]></title>
            <link>https://medium.com/@markmunyaka/build-and-deploy-medusa-using-railway-cloudflare-and-neondb-b6086860490d?source=rss-8a038be42f1a------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6086860490d</guid>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[railways]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[medusajs]]></category>
            <dc:creator><![CDATA[Mark Munyaka]]></dc:creator>
            <pubDate>Sun, 18 Aug 2024 13:47:32 GMT</pubDate>
            <atom:updated>2024-08-18T13:47:32.018Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Build and Deploy Medusa: Using Railway, Cloudflare, and NeonDB</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lpMollCoRagJquxAlMlRSg.png" /><figcaption>Cover</figcaption></figure><p>In this article, you will learn how to deploy a <a href="https://medusajs.com/">Medusa</a>-powered ecommerce backend. You will deploy your store’s Medusa backend server to <a href="https://railway.app/">Railway</a>, the Store Admin frontend to <a href="https://cloudflare.com/">Cloudflare</a></p><p>By the end of this tutorial, you’ll have a fully functional Medusa e-commerce backend running in the cloud, ready to serve customers and manage your business. Let’s dive in and bring your Medusa store to life on the web!</p><p>The method used to deploy Medusa to production is a manual method. In another tutorial, I will provide an automated method of deployment to production.</p><h3>Prerequisites</h3><p>Before starting you must have the following:</p><ul><li><a href="https://nodejs.org/en/download/package-manager">Node.js 16.14.0</a> or later</li><li>Git — <a href="https://git-scm.com/downloads">Download it here</a></li><li>Railway account — <a href="https://railway.app/login">Sign up here</a></li><li>GitHub account — <a href="https://github.com/join">Sign up here</a></li><li>Cloudflare account — <a href="https://dash.cloudflare.com/sign-up/">Sign up here</a></li><li>Neon account — <a href="https://console.neon.tech/signup">Sign up here</a></li></ul><h3>Create a PostgreSQL Database for Medusa on Neon</h3><p>Using a serverless Postgres database powered by Neon lets you scale down to zero, which helps you save on compute costs.</p><p>To get started, go to the <a href="https://console.neon.tech/app/projects">Neon console</a> and create a project. This creates a Postgres database.</p><p>Copy the Connection String of your database in the Connection Details panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CnoTlrjCU5X-elCs" /></figure><p>The Neon connection string will have the following format:</p><pre>postgresql://&lt;user&gt;:&lt;password&gt;@&lt;endpoint_hostname&gt;.neon.tech:&lt;port&gt;/&lt;dbname&gt;?sslmode=require</pre><ul><li>&lt;user&gt; is the database user.</li><li>&lt;password&gt; is the database user’s password.</li><li>&lt;endpoint_hostname&gt;.neon.tech is the host with neon.tech as the top-level domain (TLD).</li><li>&lt;port&gt; is the Neon port number. The default port number is 5432.</li><li>&lt;dbname&gt; is the name of the database. neondb is the default database created with each Neon project if you do not define your own.</li><li>?sslmode=require is an optional query parameter that enforces SSL mode for better security when connecting to the Postgres instance.</li></ul><p>Save the connection string somewhere safe.</p><h3>Create a new Medusa commerce application</h3><p>Medusa is a toolkit for developers to create digital commerce applications. In its simplest form, Medusa is a Node.js backend with the core API, plugins, and modules installed through npm.</p><p>Make sure your current working directory is the one where you intend to create a project.</p><p>In your terminal, run the following command to install the Medusa CLI. We will use it to install the Medusa server.</p><pre>npm install @medusajs/medusa-cli -g</pre><h3>Create a new Medusa project</h3><pre>medusa new my-medusa-store</pre><p>You will be asked to specify your PostgreSQL database credentials. Choose “Skip database setup”.</p><p>A new directory named my-medusa-store will be created to store the server files.</p><h3>Configure Database</h3><p>Add the connection string to your Neon database as the DATABASE_URL in your environment variables. Inside my-medusa-store create a .env file and add the following:</p><pre>DATABASE_URL=postgresql://&lt;user&gt;:&lt;password&gt;@&lt;endpoint_hostname&gt;.neon.tech:&lt;port&gt;/&lt;dbname&gt;?sslmode=require</pre><h3>Seed Database</h3><p>Run migrations and seed data to the database by running the following command:</p><pre>cd my-medusa-store<br>npx medusa seed --seed-file=&quot;./data/seed.json&quot;</pre><h3>Start your Medusa backend</h3><pre>npx medusa develop</pre><p>The Medusa server will start running on port 9000.</p><p>Test your server:</p><pre>curl localhost:9000/store/products</pre><p>If it is working, you should see a list of products.</p><h3>Log into Medusa Admin Dashboard</h3><p>Once the project is prepared, the Medusa backend will start. Visit localhost:7001 to view the admin dashboard in your browser. Use the Email admin@medusa-test.com and password supersecret to log in.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/0*MsbZVaPI3UZbLB0p" /></figure><p>Once you’re logged in, you can start using Medusa!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F6xdMEKBxxIF3P51" /></figure><h3>Deploy Medusa Admin to Cloudflare</h3><p>We will deploy the Medusa Admin application to Cloudflare Pages.</p><h3>Create GitHub Repo</h3><p>Hosting providers like Cloudflare allow you to deploy your project directly from GitHub. This makes it easier for you to push changes and updates without having to manually trigger the update in the hosting provider.</p><blockquote><em>NOTE:</em></blockquote><blockquote>Even though you are just deploying the admin, you must include the entire Medusa backend project in the deployed repository. The build process of the admin uses many of the backend’s repos.</blockquote><p>Copy the contents of your local Medusa project directory, my-medusa-store into a new folder. You can name it medusa-admin</p><p>The medusa-admin directory will be used to deploy the Medusa Admin Dashboard.</p><p>Create a new GitHub repo based on this directory to handle all the config related to the admin only.</p><h3>Configure Build Command</h3><p>In the package.json file of medusa-admin, change the build script for the admin as follows:</p><pre>&quot;scripts&quot;: {<br>  //other scripts<br>  &quot;build:admin&quot;: &quot;medusa-admin build --deployment&quot;,<br>}</pre><blockquote><em>NOTE:</em></blockquote><blockquote>When using --deployment option, the backend&#39;s URL is loaded from the MEDUSA_ADMIN_BACKEND_URL environment variable. You will configure this environment variable in a later step.</blockquote><h3>Preparing Deployment</h3><p>Log in to your <a href="https://dash.cloudflare.com/">Cloudflare Dashboard</a> and select Workers &amp; Pages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4x5zUL-7XpWKmPne" /></figure><p>Select <strong>Create application</strong> then <strong>Pages</strong> then <strong>Connect to Git</strong>.</p><p>You will be prompted to sign in with your preferred Git provider.</p><p>Next, select the GitHub project for your Medusa Admin repo.</p><p>Once you have selected a repository, select <strong>Install &amp; Authorize</strong> and <strong>Begin setup</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dGBEyYsH0TGHliIp" /></figure><p>You can then customize your deployment in Set up builds and deployments.</p><p>Your project name will be used to generate your project’s hostname.</p><h3>Configure Build settings</h3><p>Set the build command of your deployed project to use the build:admin command:</p><pre>npm run build:admin</pre><p>Set the output directory of your deployed project to build.</p><p>Add the environment variable MEDUSA_ADMIN_BACKEND_URL and set its value to localhost:9000 provisionally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/0*lqGht20P_Sdkgb4C" /></figure><h3>Configure paths</h3><p>To configure which paths are included and excluded, go to your Pages project &gt; Settings &gt; Builds &amp; deployments &gt; Build watch paths.</p><p>Trigger the build when changes occur within the medusa-admin directory:</p><ul><li>Include paths: medusa-admin</li><li>Exclude paths: ``</li></ul><h3>Save Configuration and Deploy Admin</h3><p>After you have finished setting your build configuration, select Save and Deploy. Your project build logs will output as Cloudflare Pages installs your project dependencies, builds the project, and deploys it to Cloudflare’s global network.</p><p>When your project has finished deploying, you will receive a unique URL to view your deployed site. This unique URL will be used as the value for the ADMIN_CORS environment variable when you deploy the Medusa backend server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*f6v_8ciDgwcEzpd4" /></figure><h3>Deploy Medusa Server to Railway</h3><p>We will deploy the Medusa Backend Server on <a href="https://railway.app/">Railway</a>. Railway provides a free trial (no credit card required) that allows you to deploy your Medusa backend along with PostgreSQL and Redis databases. This is useful mainly for development and demo purposes. <a href="https://railway.app/login">Sign up for a Railway account</a> if you haven’t already and proceed with the following steps.</p><h3>Create GitHub repo</h3><p>Create a new directory named medusa-server.</p><pre>mkdir medusa-server</pre><p>Copy the contents of your local Medusa project, my-medusa-store directory into the newly created medusa-server folder.</p><pre>cp -r my-medusa-store/ medusa-server/</pre><p>Create a new GitHub repo using the medusa-server directory. This will be the GitHub repo that Railway will use for deploying the Medusa backend server for your store.</p><h3>Add Railway Configuration File</h3><p>Add in the root of medusa-server the file, railway.toml, with the content based on the package manager of your choice:</p><blockquote><em>NOTE:</em></blockquote><blockquote>To avoid errors during the installation process, it’s recommended to use yarn for installing the dependencies. Alternatively, pass the --legacy-peer-deps option to the npm command.</blockquote><p>Using yarn:</p><pre>[build]<br>builder = &quot;NIXPACKS&quot;<br><br>[build.nixpacksPlan.phases.setup]<br>nixPkgs = [&quot;nodejs&quot;, &quot;yarn&quot;]<br><br>[build.nixpacksPlan.phases.install]<br>cmds=[&quot;yarn install&quot;]</pre><p>Or using npm:</p><pre>[build]<br>builder = &quot;NIXPACKS&quot;<br><br>[build.nixpacksPlan.phases.setup]<br>nixPkgs = [&quot;nodejs&quot;, &quot;npm&quot;]<br><br>[build.nixpacksPlan.phases.install]<br>cmds=[&quot;npm install --legacy-peer-deps&quot;]</pre><h3>Configure Server for Production</h3><p>Open the medusa-config.js file in your medusa-server directory.</p><p>Update the following parts to enable caching using Redis.</p><p>Uncomment the inner part of the following section:</p><pre>const modules = {<br>  /*eventBus:<br>    resolve: &quot;@medusajs/event-bus-redis&quot;,</pre><p>Uncomment the following section as well:</p><pre>// Uncomment the following lines to enable REDIS<br>// redis_url: REDIS_UR</pre><p>It then becomes:</p><pre>//...<br>const modules = {<br>  eventBus: {<br>    resolve: &quot;@medusajs/event-bus-redis&quot;,<br>    options: {<br>      redisUrl: REDIS_URL<br>    }<br>  },<br>  cacheService: {<br>    resolve: &quot;@medusajs/cache-redis&quot;,<br>    options: {<br>      redisUrl: REDIS_URL<br>    }<br>  },<br>};<br><br>/** @type {import(&#39;@medusajs/medusa&#39;).ConfigModule[&quot;projectConfig&quot;]} */<br>const projectConfig = {<br>  jwtSecret: process.env.JWT_SECRET,<br>  cookieSecret: process.env.COOKIE_SECRET,<br>  store_cors: STORE_CORS,<br>  database_url: DATABASE_URL,<br>  admin_cors: ADMIN_CORS,<br>  redis_url: REDIS_URL<br>};<br>//...</pre><p>Commit your changes, and push them to your remote GitHub repository. Once your repository is ready on GitHub, log in to your Railway dashboard.</p><h3>Create Project + Redis</h3><p>On the Railway Dashboard, click on the <strong>New Project</strong> button and choose from the list the <strong>Deploy Redis</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/0*cLGiHcllOn78Ti2K" /></figure><p>A Redis instance will be created and, after a few seconds, you will be redirected to your project page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*MwtYUQmDDhA7Yjj6" /></figure><h3>Deploy Medusa in Server Mode</h3><p>In this section, you’ll create a Medusa backend instance running in server runtime mode.</p><p>In the same project view, click on the <strong>Create</strong> button and choose the GitHub Repo option. If you still haven’t given GitHub permissions to Railway, choose the <strong>Configure GitHub App</strong> option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/0*oM1E0YYU8y2cv5Z_" /></figure><h3>Configure Medusa Backend Environment Variables</h3><p>To configure the environment variables of your Medusa backend, click on the GitHub repo card and choose the Variables tab and add the following environment variables:</p><pre>PORT=9000<br>JWT_SECRET=something<br>COOKIE_SECRET=something<br>DATABASE_URL=postgresql://dominggobana:JyyuEdr809p@df-hidden-bonus-ertd7sio.us-east-3.aws.neon.tech/storedb?sslmode=require<br>REDIS_URL=${{Redis.REDIS_URL}}<br>ADMIN_CORS=&lt;CLOUDFLARE-ADMIN-URL&gt;</pre><ul><li>JWT_SECRET and COOKIE_SECRET should be unique and secure values</li><li>DATABASE_URL is the connection string to your Neon hosted Postgres database</li><li>REDIS_URL references the value from the Redis database you created earlier. ADMIN_CORS should be replaced with the URL generated from the admin deployed on Cloudflare.</li></ul><h3>Configure Start Command</h3><p>Click on the GitHub repository’s card, select the <strong>Settings</strong> tab and scroll down to the <strong>Deploy</strong> section. Click on the <strong>Start</strong> command button and paste the following command:</p><pre>medusa migrations run &amp;&amp; medusa start</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/538/0*YNhtlhzZWma8aNF4" /></figure><h3>Define Root Directory for Deployment</h3><p>Select the <strong>Settings</strong> tab and scroll down to the <strong>Root Directory</strong> section. Set the directory to the medusa-server directory containing your Medusa app code.</p><h3>Set Watch paths</h3><p>To prevent unnecessary rebuilds, it is important to set the watch paths. Set the watch-paths to medusa-server/**.</p><h3>Add Domain Name</h3><p>Click on the Medusa server runtime card and select the <strong>Settings</strong> tab and scroll down to the <strong>Networking</strong> section. Either select <strong>Custom Domain</strong> or select <strong>Generate Domain</strong> to generate a random button.</p><h3>Deploy Changes</h3><p>At the top left of your project’s dashboard page, there’s a <strong>Deploy</strong> button that deploys all the changes you’ve made so far.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/509/0*jjeJSpWIVYTwoMBP" /></figure><p>Click on the button to trigger the deployment. The deployment will take a few minutes before it’s ready.</p><h3>Test the Backend</h3><p>Once the deployment is finished, you can access the Medusa backend on the custom domain/domain you’ve generated.</p><p>For example, you can open the URL &lt;YOUR_APP_URL&gt;/store/products which returns the products available on your backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*KP7IQkU0MK1d7aQu" /></figure><h3>Health Route</h3><p>Access &lt;YOUR_APP_URL&gt;/health to get health status of your deployed backend.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/571/0*syfKtWs9lBLdG_Xx" /></figure><h3>Test the Admin</h3><p>Revisit your Cloudflare Dashboard and open the Settings page for your live admin project. Update the value for the environment variable MEDUSA_ADMIN_BACKEND_URL with the URL to your deployed Medusa backend server on Railway.</p><p>Save the settings and rebuild your admin deployment.</p><p>Visit the URL to your Medusa Admin and log in using the user you created in the previous steps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bWo7lqhlYbINPhzg" /></figure><p>If all is working you should be able to log in to your Admin dashboard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IDJaFGlSJC252ZEh" /></figure><h3>Conclusion</h3><p>Congratulations! You’ve successfully deployed your Medusa e-commerce backend to production. Your backend is now running on Railway, while your admin dashboard is hosted on Cloudflare Pages. This setup provides a robust, scalable foundation for your online business.</p><p>By following this guide, you’ve learned how to:</p><ul><li>Set up the Medusa admin dashboard on Cloudflare Pages</li><li>Configure and deploy the Medusa backend server on Railway</li><li>Connect all components to work seamlessly together</li></ul><p>With your store now live, you’re ready to start customizing your shop, adding products, and processing orders. Remember to regularly update your deployment as new features and security patches are released for Medusa. As you continue to grow your e-commerce business, explore Medusa’s extensive plugin ecosystem and advanced features to enhance your store’s functionality. Happy selling!</p><h3>Resources</h3><p><a href="https://github.com/Marktawa/golden-embers">GitHub Repo</a></p><h3>Author</h3><p><a href="https://marktawa.github.io/personal-portfolio">Mark Munyaka</a></p><p>GitHub: <a href="https://github.com/Marktawa">@Marktawa</a><br>Twitter: <a href="https://twitter.com/McMunyaka">@McMunyaka</a></p><h3>Hire Me</h3><p>If you found this guide helpful and would like assistance in setting up your own Medusa-powered ecommerce store, I would be happy to help! As an experienced Medusa and Next.js developer, I can provide the following services:</p><ul><li>Initial setup and configuration of your Medusa backend and Next.js storefront</li><li>Deployment of your Medusa store on AWS, Railway, Digital Ocean, and any other platform</li><li>Integration with Neon Postgres, Stripe, Meilisearch, SendGrid, and other plugins</li><li>Customization and branding of your store’s design and functionality</li><li>Ongoing maintenance, updates, and feature enhancements</li><li>Performance optimization and scaling guidance</li></ul><p>To discuss your project and get a quote, please feel free to contact me at <a href="/service/mailto:markmunyakapro@gmail.com">markmunyakapro@gmail.com</a> or connect with me on <a href="https://www.linkedin.com/in/mark-tawanda-munyaka-a878137b">LinkedIn</a> or <a href="https://discord.com/users/558354133170782254">Discord</a>. I look forward to hearing from you!</p><h3>Sponsor</h3><p>Support my passion for sharing development knowledge by making a donation to my <a href="https://www.buymeacoffee.com/markmunyaka">Buy Me a Coffee</a> account. Your contribution helps me create valuable content and resources. Thank you for your support!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/260/0*xQ3_yZmSxuEtTXTb" /></figure><p><a href="https://www.buymeacoffee.com/markmunyaka">Buy Me A Coffee</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6086860490d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>