Ninja Space Content Tech Blog

Deploying a PostgreSQL database with HEROKU and getting SSL off error

February 18, 2021
I'm currently working on building a postgres database for a new project and wanted to get what I have so far deployed on Heroku. Something has changed since I've last deployed a database(db) project on Heroku, which was only 2 months ago!

When I tried to seed my data on Heroku after doing a git push, I kept getting this error in my terminal "UnhandledPromiseRejectionWarning: error: no pg_hba.conf entry for host"..."SSL off". This was an error that I've never encountered before.

After a quick Google, I found that someone also had the same issue on stack overflow. It's definitely related to ssl. See more on the stack overflow link. Since I am working with node, I've found the Heroku documentation regarding this and it was very thorough. See Heroku's main resource on postgres ssl issue: https://devcenter.heroku.com/articles/heroku-postgresql#heroku-postgres-ssl.

If you're also working on a postgres database with node. Here's the exact thing I had to model after below:

const { Client } = require('pg');

const client = new Client({
 connectionString: process.env.DATABASE_URL,
 ssl: {
 rejectUnauthorized: false
 }
});

client.connect();
Note that this is the code you will need to deploy with for Heroku only. For development, make sure the connection string is set locally. It will cause errors when you use the model code above for developing but don't worry, use the snippet for Heroku deployment. The key thing is for deployment, you need to add the ssl: {rejectUnauthorized: false} for Heroku. After I've deployed on Heroku, I ran my seed data and saw that my seed data was successfully shown on my deployed link. I commented out the model snippet and then, just have my connection string to my localhost again while I'm developing. I hope this helps you!
 

Installatron is a nightmare to use as a Contact Us Form

February 6, 2021
I recently deployed one of my websites on Godaddy's shared web hosting and decided to use one of their third party integrations called Installatron that's under their Cpanel. It has been a nightmare to get it working, even though it seems like the easiest thing to integrate.

I have talked to over 5 different tech support reps from Godaddy via their chat tool and it seems like the chat gets timed out or something because like every 30 or 45 minutes, I get a new tech support person. It's a pain and it's like I'm stuck in a loop. First, they said I have to use an email address that is linked to the domain so I did that. Then, they said, I should try using a different email address and I tried that. And then, they said they have limited resources to integrating this tech because it's a third party. If it is this difficult to figure out, I really think they shouldn't list Installatron as a solution under their Cpanel. 

After a few weeks of not getting this figured out because the last Godaddy tech support person totally ghosted me, today, I've decided to give up completely. I uninstalled it and feel relieved.

I suggest finding another way to create a Contact Us form. I ended up using a Node library called Nodemailer.
 

I did the chicken dance before my four interviews with a big six company

February 5, 2021
I had an interview with one of the big six companies earlier today. When I say 'big six', I'm referring to one of the following: Amazon, Facebook, Google, Netflix, Apple or Microsoft. I'm not going to tell you which one because I signed an NDA and I want to go further and don't want to jinx anything by telling you the exact one. I'll let you guess!

The company had me do 4 interviews in one day and because we're still in a pandemic, it was done remotely. Normally, they would have me come to their office for these back-to-back interviews but I was thankfully able to do this all from my home via video conferencing.

I've never been interviewed by a big six company before so this was a very unique and intense interview day. I'm pretty exhausted from the mental stress of doing this but I understand why they do it. They want to make sure they get the right candidate for the job. They're the best tech companies because of the people they hire.

There were technical parts and behavioral parts to the questions they were asking me. Each interview was 50 - 1 hour long. I had 30 minute breaks after the first two and only a 15 minute break between my third and fourth interview. After the near 5 hour process, I was really beat.

Before the first interview started, I was so nervous. With four interviews in one day with 6 different people, I was questioning why I am putting myself through this mental anguish when I felt that I wasn't ready yet. I started doing the chicken dance around the house to get my nerves out before my interview process started. It didn't seem to be working.

I jumped up and down and started doing chants while swinging my arms in crazy motions. I really thought I was losing my mind. I've never been so nervous for an interview before. I just graduated from a coding bootcamp in Dec 2020 and doing a carrier shift. It was humbling to meet my interviewers, who are so advanced in their careers and you can just tell that they are all so intelligent.

All in all, even if I don't get the job (which they said I would find out whether I do or not next week), I know what I need to work on to increase my chances of getting hired. If you're actively interviewing like me, hang in there. Make sure you're finding the job that fits your exact skillset.
 

Deploying React App on AWS Beanstalk

January 24, 2021
Here are the steps that I took to deploy my React App today: 
  1. First sign up for a free AWS account
  2. Create a new app in AWS Beanstalk
  3. Use git to bundle my source according to instructions here: $ git archive -v -o myapp.zip --format=zip HEAD
  4. One thing that I noticed that AWS Beanstalk looks for to run the files in there server.js (back-end) and client folder (front-end). So I'll need to make some changes. Example: my server file should be named server.js and not "index.js" like I have now. Also, they run the server on PORT 8081. So if you've configured your PORT to 4000 or whatever in your file, you'll need do a configuration change or I'm just going to try to change it in my file directly.
  5. (Still in process to deploy -- stay tuned)
 

Hosting React App on Godaddy Hosting via cpanel

January 24, 2021
Through GoDaddy, I pay shared hosting for one of my React apps. It was quite easy. After I run a build, I just drag over some files and then it was done.

Steps to use Cpanel from Godaddy's Shared Hosting to host a React App

Here are the steps I took to complete the entire hosting process:
  1. After you've logged into Godaddy with your account information, go to the cpanel File Manager part of Godaddy for your hosting account. Go to 'settings' to check the box next to "Show Hidden Files" or you won't be able to see the .htaccess file you're going to create for the build in step 3.
  2. After you've build out the "build" folder of the React app on your IDE, you'll have to have those files and sub-folders under that build folder uploaded to the public_html folder of your File Manager in Godaddy. Remember to upload the individual items under the "build" folder and not just the entire build folder. One thing that I had to improvise from a lot of the instructions I've found on the web for this was I couldn't just simply copy and paste my static folder within the build folder over to the file manager (Note: I don't have FileZilla). After moving the other files, what I had to do was manually created a 'static folder' and two more sub-folders: 'css' and 'js'. Inside the css and js folders, I then copied the corresponding files to upload them there. 
  3. Within the same level of your build files, you'll need to add an .htaccess file and edit it's content with the following:
    <IfModule mod_rewrite.c>
    
     RewriteEngine On
     RewriteBase /
     RewriteRule ^index\.html$ - [L]
     RewriteCond %{REQUEST_FILENAME} !-f
     RewriteCond %{REQUEST_FILENAME} !-d
     RewriteCond %{REQUEST_FILENAME} !-l
     RewriteRule . /index.html [L]
    
    </IfModule>
    Then, click "Save Changes".

My site successfully deployed on the Godaddy shared hosting account by utilizing these 3 main steps listed above.

Some helpful resources on this: 
https://stackoverflow.com/questions/40146067/i-have-godaddy-shared-web-hosting-i-need-to-host-node-js-website-can-host-site

https://medium.com/@pampas93/host-your-node-js-app-on-shared-hosting-go-beyond-localhost-73ab923e6691

My tech stack for the React app included node.js and express as well.

The files you will need to upload include everything in the build folder where you built your React app and then manually create the "static" folder, the two sub-folders and go into them individually and upload the files to all of the sub-folders. I hope that's helpful!

Updates to make in React App and what files to change in the Cpanel

When you make an update to your React code and run a build. You'll need to update a few files for hosting, of course. These changes are in the Public folder of the Godaddy Shared Hosting Cpanel. They include the asset-manifest.json, index.html and inside the static folder that's inside the public folder: everything in css folder and everything in js folder
 

About Ninja Space Content


Ninja Space Content I have been building simple websites on my own since 2008 and currently run several websites at the moment, including this one. I used to be an account manager for an affiliate/e-commerce company, helping affiliates grow their sales so I have some knowledge on the business side and client side of affiliate marketing. During the Covid-19 pandemic, I completed a JavaScript coding bootcamp and graduated in Dec 2020. I've been working as a contractor for a few software companies ever since.
Note: links to resources and promoting special deals may allow me to earn a small commission from each sale.