Coding Journal

Jordan Vidrine

Daily Coding Journal

An experienced business owner + musician with a demonstrated history of management in the Energy sector and an insatiable appetite for learning new and complex skills. Transitioning from an ownership role & seeking employment in Web Development as a Jr Full Stack Developer.

July 23rd 2019

Today I pushed my app in development to Heroku for testing and to show a couple of friends. It is now live at jbv-drawing-prompt-app.herokuapp.com

During the process I encountered a couple of CORS issues as well as some database connection issues. It made me glad that I added a console log to the mongodb connection JS file that either alerts ‘Connected To Dabase’ or ‘Could not connect to database’

I got everything to work by doing the following:

1. Changing my links the fetch() calls to be relative. Ie. From fetch('localhost:3000/prompt') to fetch('/prompt')

2. Using the cors npm package and having my express app use it by requiring it and adding app.use(cors()) to my express js file.

3. Since my app uses DELETE and other methods that the regular cors middleware does not cover, I also had to enable ‘pre-flight’ cors to the app by adding app.options('*',cors())

4. Lastly, I logged into my MongoDB atlas account and whitelisted any IP address that is trying to make a connection to the database.

I spent the last hour or so of my day going through more NodeJS video course work.

Back to blog...