Deploy to Heroku Cloud
Fullstack Social iOS NodeJS REST
For us to access our application from anywhere on the internet, we'll have to deploy our application onto some kind of cloud platform. There are many different platforms out there but the one I find easiest to use is Heroku. In this lesson I'll walk through how to create a Heroku app through the command line and also deploying our NodeJS code. Lastly, we'll need to configure a few things in our settings to make sure the application is working correctly without crashes.

Comments (14)
Nikhil Pandey
4 years ago
Hi Brian, Can you please include a lecture on deploying on AWS too.
Brian Voong
4 years ago
Nikhil Pandey
4 years ago
Hi Brian, Yes I mean to deploy on our own EC2 instances. See Heroku I have used but it’s a honey trap, maintaining your own AWS instances are better.
ogarci10
4 years ago
Hello Brian, Can you include a lecture on deploying on Google Cloud?
Brian Voong
4 years ago
ogarci10
4 years ago
No I have not, but thank you for the link! I will look over it.
romulusc
4 years ago
Hi Brian. Deploy successful here. I was thinking for a bonus lesson on some bug fixes maybe. I've notices I can create a post on the web app but i get a 404 response on the ios side and I did update the url in handlePost() in CreatePostController. I was wondering if handlePost can be moved to Service. All the best
Brian Voong
4 years ago
romulusc
4 years ago
Yes no route, just fixed that in CreatePostController where in: @objc fileprivate func handlePost() { let url = "http://localhost:1337/post" ..... } i was replacing the url with the app's heroku url (baseUrl) string instead of: let url = "\(baseUrl)/post"
Brian Voong
4 years ago
romulusc
4 years ago
still, creating a post now in IOS I get error 500, tried a few times. I don't get an error if I upload a profile picture though.
Brian Voong
4 years ago
romulusc
4 years ago
It's working Brian. Once I fixed that route (which by the way is not in the Service class, it has been left in the CreatePostController class) I was getting this last error 500 because I was on the mac connected to the personal hotspot on the iphone while I was away from home and I was having problems reaching Heroku. Once i got home on the fibre broadband all working fine :) . Many thanks
Brian Voong
4 years ago
Dustin Doosun Yang
4 years ago
Hello Brian, I've deployed using heroku. I have an issue with rendering. do you have an idea why it shows like that? https://dustin-social-app.herokuapp.com/
Brian Voong
4 years ago
wasy2811
4 years ago
hello, im actually having the same issue as well? is there a additional step we may be missing https://whtlabel-portal.herokuapp.com/login
Brian Voong
4 years ago
wasy2811
4 years ago
sent. It seems like my assets folder is not being properly found or ignored.
wasy2811
4 years ago
were you able to resolve your issue? It seem like we may have similar problems.
Brian Voong
4 years ago
Brian Voong
4 years ago
wasy2811
4 years ago
doing so causes 500 errors after login saying cant find files Error: ENOENT: no such file or directory, open '/app/views/pages/home/available-items.ejs'
Brian Voong
4 years ago
mdoor1123
3 years ago
Brian & everyone, this worked for me. Any idea why .gitignore was blocking the deployment? Thanks, Mike
Setwork44
3 years ago
mate how do i get rid of .gitignore?
hflournoy
3 years ago
Brian, I noticed that we still have a let url = "http://localhost:1337/post" in our CreatePostController.swift --> Is there a way to refactor this so that this line calls our baseUrl in our Service.swift file? --> ...or should we just change both links when switching from local testing to deployed testing? Cheers, Champe
Brian Voong
3 years ago
hflournoy
3 years ago
Got it! Thank you
omari
3 years ago
Hi Brian, why are we using S3 Buckets but then deploy the node app to Heroku or Google Cloud ?
Brian Voong
3 years ago
bc24102
3 years ago
I also had an issue with rendering when deploying on Heroku. The assets folder wasn't being loaded as others had mentioned. Removing the .gitignore solved the issue.
Setwork44
3 years ago
how do your remove .gitignore? I'm having the same issue
Setwork44
3 years ago
What happened to the Friends panel?
Setwork44
3 years ago
im getting "zsh: command not found: brew"
Setwork44
3 years ago
downloaded homebrew now fixed
Setwork44
3 years ago
Does anyone else know how to remove .gitignore? Theres no nav bar and the sign in button isnt even working.
JMan
2 years ago
Hey Brian, There is this message that tells me to set this value called "tustProxy" too true in sails.config.http.middleware. I think it is the reason behind my application not being able to launch, here is the full message. Also, note that since `sails.config.http.trustProxy` is set to `false`, secure cookies (and potentially all sessions+login over "https://") may not work if your app is hosted behind a proxy or load balancer -- for example, on a PaaS like Heroku or EBS.
JMan
2 years ago
sorry "trustProxy"*
Brian Voong
2 years ago
JMan
2 years ago
Do you think that it is causing my application error when I try to deploy?
Brian Voong
2 years ago
JMan
2 years ago
I believe that I found the solution to the error, although just out of interest, what is trust proxy and should I set it to true? if so where?
Brian Voong
2 years ago
JMan
2 years ago
Ok, I believe that I set it to true, if anyone else was wondering I was confused because I set it to true in middleware/order but you just probably just set it true above middleware { } and that gave me no errors.. If anything else comes up when I deploy I'll let you know.
JMan
2 years ago
Please excuse my poor grammar I was in a rush to leave...lol
gerkov77
2 years ago
Hey Brian , I jumped over here before implementing like features and deployed the app to Heroku. I am landing on the signup page (customauth/login loads fine too) BUT I cannot sign in with any of my users, neither can I sign up whith a new user, I am sent back to the same empty login page.. here is some tail of heroku logs: ' 2021-02-21T23:41:35.501655+00:00 heroku[router]: at=info method=PUT path="/api/v1/entrance/login" host=mysocial-app-greg.herokuapp.com request_id=e60b9ea3-905e-4b82-b917-d00dd6b133aa fwd="86.59.184.189" dyno=web.1 connect=1ms service=428ms status=200 bytes=253 protocol=https 2021-02-21T23:41:35.765879+00:00 app[web.1]: <- GET / (96ms 302) 2021-02-21T23:41:35.767597+00:00 heroku[router]: at=info method=GET path="/" host=mysocial-app-greg.herokuapp.com request_id=506c9136-4b9d-4603-9f70-b47540efeb7b fwd="86.59.184.189" dyno=web.1 connect=1ms service=101ms status=302 bytes=278 protocol=https 2021-02-21T23:41:35.994690+00:00 app[web.1]: <- GET /login (99ms 304) 2021-02-21T23:41:35.994747+00:00 app[web.1]: ° 2021-02-21T23:41:35.996238+00:00 heroku[router]: at=info method=GET path="/login" host=mysocial-app-greg.herokuapp.com request_id=676dca09-af07-4d33-80d6-0f97c52f2e8f fwd="86.59.184.189" dyno=web.1 connect=1ms service=105ms status=304 bytes=181 protocol=https 2021-02-21T23:41:36.566179+00:00 heroku[router]: at=info method=GET path="/socket.io/?__sails_io_sdk_version=1.2.1&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket" host=mysocial-app-greg.herokuapp.com request_id=c8490d01-1b53-4a30-a58d-31f66caf270c fwd="86.59.184.189" dyno=web.1 connect=1ms service=2ms status=400 bytes=110 protocol=https ' Why is this happening? Greg
gerkov77
2 years ago
I have removed .gitignore and .npmignore too - same is happening.. :(
gerkov77
2 years ago
in js console: failed: Error during WebSocket handshake: Unexpected response code: 400 ??
gerkov77
2 years ago
Ok, now works! I have added some extra code due to over-stackoverflowing the issue and adding "secure: true" to session.js. Removed, and now works! .npmignore and .gitignore had to be removed basically
Jason1024
2 years ago
if anyone has the assets folder issue this page maybe can help you , https://stackoverflow.com/questions/17928682/html-pictures-not-showing-up-on-heroku
Christopher J. Roura
2 years ago
I apologize if this is a really stupid question. I have made my app using MongoDB Atlas because I can no longer obtain a mlab instance through Heroku. With that said would this deploy to Heroku Cloud still work even if I am using MongoDB Atlas?
Christopher J. Roura
2 years ago
Also, I have had the same issues as many others with the gitignore file causing the assets to not exist. Is there a way to modify the gitignore instead of deleting it or commenting it all out so it can work with the assets?
BrianVoongLBTA
2 years ago
HELP & SUPPORT