<?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>Forem: Karan Sharma</title>
    <description>The latest articles on Forem by Karan Sharma (@karan_347).</description>
    <link>https://forem.com/karan_347</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%2F781474%2Fe2293c09-d05b-4a16-a29a-009cb64248c7.jpeg</url>
      <title>Forem: Karan Sharma</title>
      <link>https://forem.com/karan_347</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/karan_347"/>
    <language>en</language>
    <item>
      <title>Frontend Security - Something to care about?</title>
      <dc:creator>Karan Sharma</dc:creator>
      <pubDate>Sun, 18 Sep 2022 13:54:36 +0000</pubDate>
      <link>https://forem.com/karan_347/frontend-security-something-to-care-about-4ej2</link>
      <guid>https://forem.com/karan_347/frontend-security-something-to-care-about-4ej2</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6x2mi13j82t1rzteebg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6x2mi13j82t1rzteebg.jpg" alt="code-1" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In recent times, modern web applications are growing at a rapid pace. Responsibility for a strong and safer application should be shared between the backend as well as the frontend. Most of the security practices were being utilized in the backend side of the code but now it's becoming equally crucial to use the best security practices that will protect the frontend side of the code because of the increased cyber attacks, after all, frontend is the main window to the whole application. So, it is better to make your application safe on the entrance as well.&lt;/p&gt;

&lt;p&gt;In this article, we’ll go through some of the common attacks that take place and the best practices that can be used to safeguard your applications from them.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Cross-Site Scripting (XSS) Attack&lt;/strong&gt; &lt;br&gt;
Cross-Site Scripting (XSS) is a form of attack whereby an attacker injects malicious scripts into a trusted website. The attacker then proceeds to send you malicious codes that look like the side script of your browser. &lt;/p&gt;

&lt;p&gt;When other users access the web application, since the browser does not know that it is malicious as it was served by the backend, this malicious script is executed. &lt;/p&gt;

&lt;p&gt;a) An attacker with a malicious script accesses the application.&lt;br&gt;
b) He fills up a form and inputs a malicious script in the form field.&lt;br&gt;
c) The malicious script reaches back-end systems via a form field data and is saved in the database.&lt;br&gt;
d) When some legitimate user accesses the application, he is served with the malicious script by the application’s backend. The browser doesn’t know it is a malicious script and executes it.&lt;/p&gt;

&lt;p&gt;The malicious scripts sent are configured to access your sensitive data, session tokens, cookies, browser history, and more.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevention&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Filter input on arrival- When the input is received, filter data based on what is expected or valid input.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Encode data on output- When user-controllable data is provided in HTTP responses, encode the output to prevent it from being executed by HTML parser. Depending on the output context, this might require applying combinations of HTML, URL, JavaScript, and CSS encoding.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use appropriate response headers- To prevent XSS in HTTP responses that aren’t intended to contain any HTML or JavaScript, we can use the Content-Type and X-Content-Type-Options headers to ensure that browsers interpret the responses in the way you intend. Eg. A JSON data should never be encoded as text/html, to prevent it from accidental execution.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;DDOS Attack&lt;/strong&gt; &lt;br&gt;
A Distributed Denial-of-Service (DDoS) attack is the process of overwhelming a website with too much traffic to a point where it crashes. Due to the high volume of DDoS attacks, the attacker manipulates hundreds or thousands of systems to generate the high traffic targeted at your web application to wear it out.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevention&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using Captcha at public-facing endpoints (login, registration, contact) — a captcha is a computer program or system intended to distinguish humans from bots.&lt;br&gt;
Most of the DOS attacks are carried out using bots. Captcha identifies bots and prevents them from making requests.&lt;/p&gt;

&lt;p&gt;Google’s reCaptcha is a highly advanced service to protect bots from abusing your applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cross-Site Request Forgery&lt;/strong&gt;&lt;br&gt;
Cross-Site Request Forgery (CSRF) involves an attacker luring you into taking harmful action on a website that has been authenticated with your login credentials. This kind of attack is mostly executed with download forms.&lt;/p&gt;

&lt;p&gt;It can be tiring to always enter your login credentials into websites that you visit frequently. You might choose to make it easier by saving your login information on the website. Although this is a common practice, it can be a problem.&lt;/p&gt;

&lt;p&gt;An attacker could send you a download link from a website that you have saved your credentials on. If you download the file, you unknowingly perform a malicious transaction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevention&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;For every session of a user, the server should generate a randomized token (CSRF Token) and send it to the client. The client can save the token, from where javascript can read it.&lt;/p&gt;

&lt;p&gt;When a web application is making an HTTP request, the application should include that randomized token (CSRF Token) in the header of each request.&lt;/p&gt;

&lt;p&gt;The value of this token should be randomly generated such that it cannot be guessed by an attacker. We should use a well-known hashing algorithm such as SHA256/512 for generating tokens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Using third-party libraries&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implementing third-party libraries to enhance the performance of your system is necessary. The more third-party software, the more functions you can execute on your web application as each one serves a unique purpose. But sometimes, these libraries might have loopholes that could expose your system to cyberattacks.&lt;/p&gt;

&lt;p&gt;For instance, if you offer a service that requires your clients to make online payments. Instead of creating your own billing software, you might choose to implement a third-party billing software that will get the job done. If the billing system isn’t well secured and suffers a security breach, your clients' payment information will be exposed and their money can be stolen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prevention&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;One sure way to prevent third-party library attacks is to scan all the third-party libraries that you use. Doing this manually can be complex and time-consuming, especially if you are dealing with a large web application. But you can automate the process by using vulnerability scanners to detect existing threats.&lt;/p&gt;




&lt;p&gt;One of the most crucial practice that every developer should know about and should often use is &lt;strong&gt;&lt;em&gt;Content Security Policy (CSP).&lt;/em&gt;&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;The main issue that comes up in XSS is the browser’s inability to distinguish between script intended to be part of your own application. A website can have multiple scripts from different sources, being used. The browser will happily download and execute any script that it comes across.&lt;/p&gt;

&lt;p&gt;Instead of blindly trusting everything that a server delivers, CSP defines the Content-Security-Policy HTTP header that allows you to create a whitelist of sources of trusted content and instructs the browser to only execute or render resources from those sources. Even if an attacker can find a hole through which to inject script, the script won’t match the whitelist, and therefore won’t be executed.&lt;/p&gt;

&lt;p&gt;A very important point to note here is that CSP provides prevention against scripts based on origins and hence it would not prevent any inline scripts from execution. Origin based whitelisting doesn’t solve the biggest threat to XSS attacks using inline script injection.&lt;/p&gt;

&lt;p&gt;CSP solves this problem by banning any inline scripts entirely. Hence we will have to move any inline js within the script tags to external script files. External scripts are already considered as the best practice. They are easier for browsers to cache, better for developers, better for minification.&lt;/p&gt;




&lt;p&gt;Cyber attacks have only grown through the period of time. Attackers seize even the slightest of the opportunity they get. So, it’s better to be more secure from your end. Protecting the application from the backend only won’t solve the issue. Frontend too, should be given a priority and should not be overlooked.&lt;/p&gt;

</description>
      <category>frontendsecurity</category>
      <category>webdev</category>
      <category>cybersecurity</category>
    </item>
    <item>
      <title>RESOURCES I USED TO LEARN BLOCKCHAIN/SMART CONTRACT PROGRAMMING</title>
      <dc:creator>Karan Sharma</dc:creator>
      <pubDate>Sat, 08 Jan 2022 15:02:20 +0000</pubDate>
      <link>https://forem.com/karan_347/resources-i-used-to-learn-blockchainsmart-contract-programming-5ejn</link>
      <guid>https://forem.com/karan_347/resources-i-used-to-learn-blockchainsmart-contract-programming-5ejn</guid>
      <description>&lt;p&gt;Blockchain was one of the hottest topics in 2021. Many people got to know about it, some started investing in cryptocurrencies or NFTs, focussing on the finance side or some started to learn smart contract programming or blockchain development, focussing on the technical side. I took part in both the worlds, finance and tech. Started investing in Bitcoin and Ethereum every week or so and along with that started learning the blockchain and its development side. As I went further learning about it, there was not a single day I remember when I didn’t got to know about a new concept around it(Now it’s every week or so 😅). I felt intimidated as well as curious at the same time. &lt;/p&gt;

&lt;p&gt;Blockchain has bought some new and interesting opportunities for us and I think it’s the right time to start investing some time in learning it as well and taking the first mover’s advantage as it's going to be a huge thing 5-10 yrs down the line. &lt;/p&gt;

&lt;p&gt;So, here is the list of few resources(and some extra one’s too 😉)  that I used to learn blockchain and smart contract development. Folks who are going to start their journey or has started, can refer this blog to get to know about few reliable resources to learn from.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. The Basics of Bitcoins and Blockchain&lt;/strong&gt;&lt;br&gt;
As a first step, to know about cryptocurrency and blockchain universe I used this book by Antony Lewis. To understand blockchain in the most easiest and non-technical way, this book is hands down the best resource out there.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqw0ifk4gnf5doqu2jtcd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqw0ifk4gnf5doqu2jtcd.jpg" alt="Blockchain basics" width="323" height="499"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Ethereum Blockchain Developer Bootcamp With Solidity&lt;/strong&gt;&lt;br&gt;
After getting to know the basics and getting familiar with few concepts, I took this course from Udemy to get to know more about blockchain but in a more technical way and learn the development side of it. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.udemy.com/course/blockchain-developer/" rel="noopener noreferrer"&gt;Ethereum Blockchain Developer Bootcamp&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Mastering Ethereum&lt;/strong&gt;&lt;br&gt;
To get my concepts more clear and refine, I used this book as a reference to know more about Ethereum and its application. I got to know more technical concepts around Ethereum blockchain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqifqw8t6q3toexn6ug50.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqifqw8t6q3toexn6ug50.jpg" alt="Mastering Ethereum" width="260" height="334"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Cryptozombies&lt;/strong&gt;&lt;br&gt;
After completing the course, I got to know about crypto zombies. It’s a zombie collectible game built using Ethereum blockchain. This course gave me more real-life application experience. After completing this, I gained some confidence and looked forward to building more stuff.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://cryptozombies.io/en/course" rel="noopener noreferrer"&gt;CryptoZombies&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Dapp University YouTube Channel&lt;/strong&gt;&lt;br&gt;
My last project on crypto zombies made me really interested in building more projects on blockchain. So, to build more projects around blockchain, I followed tutorials on this channel and they were awesome!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/c/DappUniversity" rel="noopener noreferrer"&gt;Dapp University&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Extra Resources&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Some of the extra resources, that I found really helpful to me, were these following resources&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://cryptodevhub.io/wiki/blockchain-development-tutorial" rel="noopener noreferrer"&gt;Crypto Dev Hub&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Ethereum Smart Contract development&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtphkpglwn2kikpbyyv1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvtphkpglwn2kikpbyyv1.jpg" alt="Ethereum book" width="177" height="218"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/OffcierCia/DeFi-Developer-Road-Map" rel="noopener noreferrer"&gt;Defi Roadmap&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://consensys.github.io/smart-contract-best-practices/" rel="noopener noreferrer"&gt;Smart Contracts Best Practices&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do you want to read the digital editions/pdf form of the books or &lt;br&gt;
checkout them before you want to buy them?&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
.&lt;br&gt;
No worries, I got you&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03afxfkoiz2s3grd38jf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F03afxfkoiz2s3grd38jf.gif" alt="yayyy" width="498" height="267"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on this &lt;a href="https://github.com/JavaKaran/Blockchain-Resources" rel="noopener noreferrer"&gt;&lt;strong&gt;link&lt;/strong&gt;&lt;/a&gt; to access the above mentioned books.&lt;/p&gt;

&lt;p&gt;Twitter – &lt;a href="//www.twitter.com/karan_346"&gt;karan_346&lt;/a&gt;&lt;br&gt;
Github – &lt;a href="//www.github.com/JavaKaran"&gt;JavaKaran&lt;/a&gt;&lt;/p&gt;

</description>
      <category>blockchain</category>
      <category>cryptocurrency</category>
      <category>smartcontract</category>
      <category>development</category>
    </item>
    <item>
      <title>How to deploy MERN application on Heroku(Easiest way!!)</title>
      <dc:creator>Karan Sharma</dc:creator>
      <pubDate>Mon, 03 Jan 2022 15:13:54 +0000</pubDate>
      <link>https://forem.com/karan_347/how-to-deploy-mern-application-on-herokueasiest-way-3i5h</link>
      <guid>https://forem.com/karan_347/how-to-deploy-mern-application-on-herokueasiest-way-3i5h</guid>
      <description>&lt;p&gt;As a beginner, when we first start building our projects, we always think of deploying our application and show it to our friends or family or share around on our social media. But there are so many portals out there and so many resources, we often get confused. I, myself, when I first started to deploy, got myself bombarded with the resources online. &lt;br&gt;
After reading and watching many articles, documentation and tutorials, I finally deployed my first project. But as I was following the resources, I faced many issues and often have to look out for more resources to fix them. &lt;br&gt;
At the end of all of that, I got an idea to write out a blog which will act as a guide to deploy the project in the most easiest way possible to help my fellow coders who have just started with their joruney.&lt;/p&gt;

&lt;p&gt;So, to make your journey a little less painful,here are the instructions to follow. Let’s start....&lt;/p&gt;

&lt;p&gt;Firstly, make sure that your Project structure looks like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9wg2u2sjfk1ev5axllf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd9wg2u2sjfk1ev5axllf.png" alt="screenshot1" width="212" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Initialise git directory in the root of your project by running the following command in cli&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Make sure you are in the root directory in cli too :)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;To deploy an application on Heroku one needs to have a Heroku account. Click on the &lt;a href="//www.heroku.com"&gt;link&lt;/a&gt; and create one.&lt;/p&gt;

&lt;p&gt;After that, download Heroku CLI and confirm the installation. To  confirm the installation, run the following command in cli&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku version
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;After that Login in  to your Heroku account with the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku login
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will prompt you to enter email and password and after successfully logging in, it will lead you to the chrome webpage of Heroku.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Next, to deploy the app we need a production build of the frontend/client side of the project.To create a production build, run the following command in the client/frontend directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run build
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: Make sure your client/frontend directory has build command under scripts section in package.json&lt;/p&gt;

&lt;p&gt;After successful build, there must be a new directory under the root directory of client/frontend by the name of “build”.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Now, add the following code at the end of server/index.js (the main/entry file of the root directory)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const path = require("path");

// This command will import the client build folder to the server.

app.use(express.static(path.resolve(__dirname, "./client/build")));

/* This command will redirect all request to index.html in build directory.*/

app.get("*", function (request, response) {
  response.sendFile(path.resolve(__dirname, "./client/build", "index.html"));
});

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

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 6&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;After that modify the package.json file in the root directory of your project by adding the following command under scripts section.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;“heroku-postbuild”: “cd client &amp;amp;&amp;amp; npm install &amp;amp;&amp;amp; npm run build”
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7 (Optional)&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Now, the next step will be creating a proc file. In the root directory make a new file with the name of Procfile and add the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web:npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 8&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;After successfully doing the above steps, its time to create the Heroku app. Run the following command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku create app-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; – Make sure that you run the above command in the root directory of your project.&lt;/p&gt;

&lt;p&gt;Also, make sure that your app name is unique, otherwise, it will keep giving errors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;Now, in the end run the following commands in order&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add . // add files in git directory

git commit -m “your message” // commit the changes made to the branch

git push heroku main // push the code to the main branch
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After executing the last line, the  app will be deployed and the url for the same will be logged in the cli.&lt;br&gt;
If you want you can also open the application using cli by running the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;heroku open 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can also access the deployed projects from the dashboard on Heroku web.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmh61fqfi2al6b2w884p.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdmh61fqfi2al6b2w884p.gif" alt="meme" width="267" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(This might happen to most of you, but not everyone)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But wait, if you click on the url, the app is not working. Why’s that?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you have a .env file in your project?&lt;/strong&gt;&lt;br&gt;
If yes, then go ahead and follow few steps to fix the issue.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1&lt;/strong&gt;: Go to your dashboard and click on the application name of the project you are currently working on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y8ay1mfy67w6ja1a286.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8y8ay1mfy67w6ja1a286.jpg" alt="screenshot2" width="800" height="384"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2&lt;/strong&gt;: After that click on settings and go down to the config vars section&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6t2wmklsax5up427gmt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe6t2wmklsax5up427gmt.jpg" alt="screenshot3" width="800" height="393"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3&lt;/strong&gt;: Click on reveal config vars and you’ll get the section to enter all the details from .env in that&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F117rmgp7fauxphee9dlt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F117rmgp7fauxphee9dlt.jpg" alt="screenshot4" width="800" height="286"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Enter the details and make sure to save at the end! :)&lt;/p&gt;

&lt;p&gt;And….there you go!! The application is now deployed and should be running just perfect.  &lt;/p&gt;

&lt;p&gt;Twitter – &lt;a href="//www.twitter.com/karan_346"&gt;karan_346&lt;/a&gt;&lt;br&gt;
Github – &lt;a href="//www.github.com/JavaKaran"&gt;JavaKaran&lt;/a&gt;&lt;/p&gt;

</description>
      <category>mern</category>
      <category>heroku</category>
      <category>beginners</category>
      <category>deploy</category>
    </item>
  </channel>
</rss>
