<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elliott Ross</title>
    <description>The latest articles on DEV Community by Elliott Ross (@elliottross23).</description>
    <link>https://dev.to/elliottross23</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F439859%2F13718bef-d2ad-4759-a1d8-a26d08bf9a40.jpg</url>
      <title>DEV Community: Elliott Ross</title>
      <link>https://dev.to/elliottross23</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elliottross23"/>
    <language>en</language>
    <item>
      <title>Deploying Headless Strapi to Netlify and Digital Ocean — Part 4: Running your Strapi app on the droplet</title>
      <dc:creator>Elliott Ross</dc:creator>
      <pubDate>Sun, 09 Aug 2020 03:46:09 +0000</pubDate>
      <link>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-4-running-your-strapi-app-on-the-droplet-i75</link>
      <guid>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-4-running-your-strapi-app-on-the-droplet-i75</guid>
      <description>&lt;h3&gt;
  
  
  Getting strapi on the server
&lt;/h3&gt;

&lt;p&gt;Since we used the NodeJS 1-click app from Digital Ocean, our server already has Git installed on it. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;SSH into your server and &lt;code&gt;cd&lt;/code&gt; into the directory where you want your app to live. In my case, I'm going to put my app in &lt;code&gt;/var/www&lt;/code&gt; and for the sake of this article I'll be using that as my path everywhere&lt;/li&gt;
&lt;li&gt;I'm using Gitlab for source control and prefer to use SSH to clone my repositories so I need to create an SSH key for it (&lt;a href="https://gitlab.com/help/ssh/README#generating-a-new-ssh-key-pair" rel="noopener noreferrer"&gt;Gitlab provides simple instructions to generate one&lt;/a&gt;). If you are using the HTTPS way then all you need to do is run your command and it will prompt for credentials&lt;/li&gt;
&lt;li&gt;Now &lt;code&gt;git clone&lt;/code&gt; your repo&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cd&lt;/code&gt; into your project root folder and run &lt;code&gt;npm install&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Here's where the NodeJS 1-click comes in handy again because they already installed &lt;code&gt;pm2&lt;/code&gt; for us (&lt;a href="https://pm2.keymetrics.io/" rel="noopener noreferrer"&gt;pm2 is a process manager&lt;/a&gt;)&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Make sure you are in the root directory of your project. For me it's &lt;code&gt;/var/www/frontendcuts-backend&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Now simply run &lt;code&gt;pm2 init&lt;/code&gt; which will generate a file named &lt;code&gt;ecosystem.config.js&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Edit that file and paste this in:
&lt;/li&gt;
&lt;/ol&gt;

&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;apps&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;strapi&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;cwd&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/var/www/frontendcuts-backend&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;replace&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt; &lt;span class="kd"&gt;with&lt;/span&gt; &lt;span class="nx"&gt;path&lt;/span&gt; &lt;span class="nx"&gt;to&lt;/span&gt; &lt;span class="nx"&gt;your&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;
      &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;npm&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;args&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;start&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;NODE_ENV&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;production&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;],&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;



&lt;ol&gt;
&lt;li&gt;We are almost there! We still need to connect the our MongoDB Atlas Cluster to the app. Once you create your cluster (&lt;a href="https://docs.atlas.mongodb.com/tutorial/create-new-cluster/" rel="noopener noreferrer"&gt;instructions here&lt;/a&gt;), make sure to give Network Access to your droplet IP Address and under Database Access you need to create a user that you will use in your connection string. &lt;/li&gt;
&lt;li&gt;Back on your server create a &lt;code&gt;.env&lt;/code&gt; file in the root folder of your project and paste the connection string from Atlas into the &lt;code&gt;DATABASE_URI&lt;/code&gt; variable (On your cluster page there's a "Connect" button). Here's an example:
&lt;/li&gt;
&lt;/ol&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;DATABASE_URI&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;mongodb+srv://&amp;lt;your-db-admin-user-name&amp;gt;:&amp;lt;password&amp;gt;@cluster0.xxxxx.azure.mongodb.net/&amp;lt;database-name&amp;gt;?retryWrites&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nb"&gt;true&lt;/span&gt;&amp;amp;w&lt;span class="o"&gt;=&lt;/span&gt;majority
&lt;/code&gt;&lt;/pre&gt;



&lt;p&gt;Make sure to add any other environment variables you might need (API keys for other services, etc)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;NOTE ABOUT YOUR DATABASE&lt;/em&gt;&lt;/strong&gt;: Because this is an existing project you &lt;em&gt;might&lt;/em&gt; have to migrate some of your strapi database collections to your atlas cluster. &lt;a href="https://strapi.io/documentation/v3.x/cli/CLI.html#strapi-configuration-dump-config-dump" rel="noopener noreferrer"&gt;Strapi provides some CLI commands to help dump and restore config collections&lt;/a&gt;.&lt;/p&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Finally let's run the app. In the root folder of your project run &lt;code&gt;pm2 start ecosystem.config.js&lt;/code&gt; and you should see some output like this:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjzxogr7gdqn6nj7pa68g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fjzxogr7gdqn6nj7pa68g.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;To verify your app is running and started up correctly you can use the &lt;code&gt;pm2 log&lt;/code&gt; command to see the output. If everything looks good, you should be able to visit your API subdomain url and see this:&lt;br&gt;&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsn3d38a6pvm92trsesl8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsn3d38a6pvm92trsesl8.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Visit your admin subdomain and you should be able to create your admin user, login, and access the entire Admin Panel.&lt;/p&gt;&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  WE DID IT!
&lt;/h2&gt;

&lt;p&gt;We now have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://frontendcuts.dev" rel="noopener noreferrer"&gt;https://frontendcuts.dev&lt;/a&gt; is our main website&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://api.frontendcuts.dev" rel="noopener noreferrer"&gt;https://api.frontendcuts.dev&lt;/a&gt; is where our headless strapi is accessible&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://admin.frontendcuts.dev" rel="noopener noreferrer"&gt;https://admin.frontendcuts.dev&lt;/a&gt; is our admin panel UI that connects to strapi backend&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Deploying Headless Strapi to Netlify and Digital Ocean — Part 3: Create and Configure our Droplet</title>
      <dc:creator>Elliott Ross</dc:creator>
      <pubDate>Sun, 09 Aug 2020 03:46:00 +0000</pubDate>
      <link>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-3-create-and-configure-our-droplet-3a5a</link>
      <guid>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-3-create-and-configure-our-droplet-3a5a</guid>
      <description>&lt;h2&gt;
  
  
  Deploying strapi API to a Digital Ocean Droplet
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating the Droplet
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Login to your Digital Ocean account (if you don't have one my shameless plug for $100 is &lt;a href="https://m.do.co/c/b0143b32b41c" rel="noopener noreferrer"&gt;here&lt;/a&gt;)

&lt;ul&gt;
&lt;li&gt;In my account I created a new project for this to keep the resources in. It's totally optional but I do recommend it&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Click the Create dropdown at the top right of the page and select Droplet&lt;/li&gt;
&lt;li&gt;We are going to use the 1-click NodeJS droplet to help us out. It comes with everything we need to run and serve our API. Click on the "Marketplace" tab and type "NodeJS" in the search box. Click on the first search result and it will select the NodeJS 1-click app for us.&lt;/li&gt;
&lt;li&gt;Scroll down and choose the Basic plan with the $5/month server (&lt;strong&gt;1 GB /&lt;/strong&gt; 1 CPU, &lt;strong&gt;25 GB /&lt;/strong&gt; SSD disk, &lt;strong&gt;1000 GB /&lt;/strong&gt; transfer) I'm using the smaller server because I'm cheap and it's more than sufficient right now.&lt;/li&gt;
&lt;li&gt;I'm not adding block storage and I'm selecting the &lt;code&gt;New York 3&lt;/code&gt; region but pick whichever region you want&lt;/li&gt;
&lt;li&gt;I'm skipping some other sections and scrolling down to "Authentication" where you should select SSH Keys. I pick one of my current keys to attach to the droplet. This allows us to login from our computer using our SSH key instead of a password and is considered more secure.&lt;/li&gt;
&lt;li&gt;Finally choose your hostname (which is your droplet name that shows up in the web console), add tags if you want, and check if you want backups&lt;/li&gt;
&lt;li&gt;Now click the magic "Create Droplet" button!&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt; I recommend following the instructions &lt;a href="https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-20-04" rel="noopener noreferrer"&gt;here for initial server setup&lt;/a&gt; that will guide you through creating a user and granting them admin privileges. It is &lt;strong&gt;&lt;em&gt;not&lt;/em&gt;&lt;/strong&gt; recommended to use root!&lt;/p&gt;

&lt;h3&gt;
  
  
  Point our domain to the Droplet
&lt;/h3&gt;

&lt;p&gt;We are going to do this before setting up our droplet to give the DNS records time to propagate&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Let's go back to Netlify and login to our account&lt;/li&gt;
&lt;li&gt;On the menu across the top click on "Domains" and select your domain for this project. In my case, I'm clicking on &lt;code&gt;frontendcuts.dev&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;We need to add a DNS record that points our API sudomain to our droplet so under the DNS Settings section click "Add a record" and you will get a popover.

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Record Type —&lt;/strong&gt; A&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Name&lt;/strong&gt; — api&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Value&lt;/strong&gt; — (your droplet IP address)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TTL in Seconds&lt;/strong&gt; — this is optional and just let's DNS know how long to cache your current record value. I like to set some of my longer term ones to 14400&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Now let's save the record and give it time to propagate while we get the Strapi API running&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Create our NGINX config
&lt;/h3&gt;

&lt;p&gt;We are using NGINX as a reverse proxy to help us out with a few things.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rate limit&lt;/li&gt;
&lt;li&gt;Enforce HTTPS and serve our SSL/TLS certificates (and with Let's Encrypt renew them automatically)&lt;/li&gt;
&lt;li&gt;Forward incoming requests to our running strapi app on 127.0.0.1:1337 (we setup the host and port in our server config in Part 2)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Digital Ocean is coming in handy again with a free tool they provide to help you with configuration: &lt;a href="https://www.digitalocean.com/community/tools/nginx" rel="noopener noreferrer"&gt;https://www.digitalocean.com/community/tools/nginx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select the NodeJS preset&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fr6btv24mmbxwa0dv5gsk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fr6btv24mmbxwa0dv5gsk.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill in your Domain&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fim4qz048oom22hmjer4s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fim4qz048oom22hmjer4s.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setup the Reverse Proxy. Your proxy_pass should use the host and port from the server config.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fj1a61l9tw3ebetyr6q95.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fj1a61l9tw3ebetyr6q95.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can see all the generated config at the bottom of the page in the "Config Files" section which is really cool.&lt;/p&gt;

&lt;p&gt;Now you can just follow the instructions in the "Setup" section to get set up on your server.&lt;/p&gt;

&lt;p&gt;Ok so now we have our NGINX being a reverse proxy for us with certificates on and we....get a 502 Bad Gateway. This is good though! It's exactly what we should see right now since we haven't setup our Strapi API yet!&lt;/p&gt;

&lt;p&gt;Time to setup the Strapi API&lt;br&gt;
&lt;a href="https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-4-running-your-strapi-app-on-the-droplet-i75"&gt;Part 4: Running your Strapi app on the droplet&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying Headless Strapi to Netlify and Digital Ocean — Part 2: The Admin Panel UI</title>
      <dc:creator>Elliott Ross</dc:creator>
      <pubDate>Sun, 09 Aug 2020 03:45:50 +0000</pubDate>
      <link>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-2-the-admin-panel-ui-1lf8</link>
      <guid>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-2-the-admin-panel-ui-1lf8</guid>
      <description>&lt;p&gt;We are going to start with what I consider the easiest part. &lt;a href="https://netlify.com"&gt;Netlify&lt;/a&gt; is a fantastic tool with a great free tier that we are going to deploy our Strapi Admin Panel (and have already deployed our Nuxt website). They offer static hosting and because Strapi's Admin Panel is a React app we can simply build it and deploy separately.&lt;/p&gt;

&lt;p&gt;Why set up the admin UI before the API? The main reason is that it's easier to hit the ground running once you launch the API server and the API won't be vulnerable to someone hijacking and setting up the admin user before we can! &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Remember: We are assuming you already have a domain and it is using Netlify DNS. For instructions on that &lt;a href="https://docs.netlify.com/domains-https/netlify-dns/"&gt;go here&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before we deploy, we just need to tweak a few settings in our Strapi project. In production we need to tell the API to not build or serve the admin panel since it will run on Netlify. Let's update the production server config:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;config/env/production/server.js&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;HOST&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;127.0.0.1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;int&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1337&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; 
    &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://api.frontendcuts.dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
    &lt;span class="na"&gt;admin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://admin.frontendcuts.dev&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
        &lt;span class="na"&gt;serveAdminPanel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; this file lives under the &lt;code&gt;/production/&lt;/code&gt; folder in env. This lets strapi know to only use it when NODE_ENV is set to 'production.'&lt;/p&gt;

&lt;p&gt;Let's go through each setting: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;host&lt;/strong&gt; — when we deploy the API to our Digital Ocean droplet we are telling the API to use 127.0.0.1 (local loopback) as our host&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;port&lt;/strong&gt; — goes with the host and adds the port&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;url&lt;/strong&gt; — tells the admin UI what the base url is for the API&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;admin.url&lt;/strong&gt; — url path for admin UI resources. This is important when running the UI on netlify! Since our admin UI builds into a folder &lt;code&gt;build/&lt;/code&gt; and all the resources live at the root folder level we need to set this so it can load the javascript, css, html, and other resources properly. It's also used in password reset.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;admin.serveAdminPanel&lt;/strong&gt; — tells the API not to serve the admin UI resources&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Ok, we are ready to deploy! Here comes the screenshots...&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy the Admin UI to Netlify
&lt;/h3&gt;

&lt;p&gt;Once logged in, click the button "New Site from Git"&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i3rv4RPh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ffstdcocji9ahi8uxgrg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i3rv4RPh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ffstdcocji9ahi8uxgrg.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Setup your build settings like this:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HVVF-C_d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a1hcvd744838hc7ms5kw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HVVF-C_d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/a1hcvd744838hc7ms5kw.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let it go and watch it build. Now we need to add a DNS record. Since you are using Netlify DNS for the primary domain we can head over to the domains page and add a domain alias:&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JweNo9L8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tgspaej0tlduidx2n4k2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JweNo9L8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/tgspaej0tlduidx2n4k2.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This change might take a few hours so be patient while DNS propagates!&lt;/p&gt;

&lt;p&gt;Now try to visit your admin site and you should see a blank white page with a loading spinner. If you open the admin console you will see that our UI resources loaded but it failed to call the API (since we don't have a server up yet!). Also note the request url it tried to call for &lt;code&gt;init&lt;/code&gt;. The base url should match the &lt;code&gt;url&lt;/code&gt; property we put in our &lt;code&gt;config/env/production/server.js&lt;/code&gt; file above.&lt;/p&gt;

&lt;p&gt;If your resources load and your init base url looks correct then congrats! we just deployed the admin UI to netlify!&lt;/p&gt;

&lt;p&gt;Now let's create our droplet and hook this thing up&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-3-create-and-configure-our-droplet-3a5a"&gt;Part 3: Create and Configure Our Droplet&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Deploying Headless Strapi to Netlify and Digital Ocean — Part 1: Intro</title>
      <dc:creator>Elliott Ross</dc:creator>
      <pubDate>Sun, 09 Aug 2020 03:45:20 +0000</pubDate>
      <link>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-1-intro-2ga0</link>
      <guid>https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-1-intro-2ga0</guid>
      <description>&lt;p&gt;This is really my first tech article and it's a 4-parter. If you have any corrections, comments, or pro tips let me know!&lt;/p&gt;

&lt;p&gt;Quick note: If you want the quick and easy solution Digital Ocean offers a 1-click install button for Strapi on a $10/month server. It's great if you don't have an existing Strapi project (Shameless plug: &lt;a href="https://m.do.co/c/b0143b32b41c"&gt;Here's my referral link for $100 in credit&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;So why did I do the deployment myself?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Be cheap and save $5 a month by running it headless&lt;/li&gt;
&lt;li&gt;I love figuring these things out&lt;/li&gt;
&lt;li&gt;I thought it would be easier to configure the admin UI to be on a subdomain&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;This guide assumes:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You already own a domain and it's using Netlify DNS&lt;/li&gt;
&lt;li&gt;You have a Digital Ocean account&lt;/li&gt;
&lt;li&gt;You have an existing strapi project in a git repository&lt;/li&gt;
&lt;li&gt;We will be using MongoDB as our backend through &lt;a href="https://www.mongodb.com/cloud/atlas"&gt;MongoDB Atlas&lt;/a&gt; (they have a generous free tier!)&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Versions&lt;/strong&gt;&lt;br&gt;
Strapi -- 3.0.1&lt;br&gt;
Node -- 12.18.0&lt;br&gt;
NPM -- 6.14.5&lt;/p&gt;




&lt;p&gt;I've been wanting to build this side project for a while and this is a perfect opportunity to build it and share how I first deployed and set it up. My side project is Front End Cuts, a place to create, contribute, manage, and search for code samples for front end development. While writing this article the only thing you can do is signup/signin and create/view a cut. More will be added later so please don't comment on the ugly look 😂&lt;/p&gt;

&lt;p&gt;This article is not for extreme beginners as I'm assuming you have some knowledge of strapi, linux/unix commands, and mongodb. Throughout the different parts I will link to guides for things that do not directly contribute to deploying Strapi.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here's what we want:&lt;/strong&gt;&lt;br&gt;
frontendcuts.dev &lt;strong&gt;--&amp;gt;&lt;/strong&gt; Frontend Nuxt site&lt;br&gt;
admin.frontendcuts.dev &lt;strong&gt;--&amp;gt;&lt;/strong&gt; Strapi Admin Panel (React app)&lt;br&gt;
api.frontendcuts.dev &lt;strong&gt;--&amp;gt;&lt;/strong&gt; Strapi server and API&lt;/p&gt;

&lt;p&gt;Let's dive in!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/elliottross23/deploying-headless-strapi-to-netlify-and-digital-ocean-part-2-the-admin-panel-ui-1lf8"&gt;Go to Part 2: The Admin Panel UI&lt;/a&gt;&lt;/p&gt;

</description>
      <category>strapi</category>
      <category>netlify</category>
      <category>digitalocean</category>
    </item>
  </channel>
</rss>
