Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hosting my MEAN stack web app on github pages

I have a project here that is on github. I created a gh-pages branch to make it hosted on github pages. The link they gave me to my hosted site is here.

I am pretty new to web apps and especially new to MEAN stack web apps. My question is - how can I access my web app now that it is hosted via github? Obviously the hosted link gives a 404 error because I don't have an index.html file in the root of the project. The "html" I have in the project is in the views folder and has an "ejs" file extension (index.ejs).

To run this app on my local machine I start an npm server:

npm start

Then I navigate to http://localhost:3000/#/home in a browser to see the app.

Is it even possible to host this app on github pages? Do I need to modify my project in some way to make it work? Also - I know I will have to change the mongoose database pointer for the database portion to work. Any pointers in the right direction would be greatly appreciated!

like image 723
httpNick Avatar asked Jun 02 '15 19:06

httpNick


People also ask

Can I deploy full stack app to GitHub Pages?

The easiest one. You should consider this if your site is fully static and its repo is hosted on GitHub. To enable it, just go to the repository settings (general tab), select a branch to deploy and set it. Once enabled, the branch selected will be served as static files over https.

Can you host a web app on GitHub Pages?

Did you know that Github will allow anyone to host their static webpages for free? The best part is that you can even use your own custom domain. Let's do this!


2 Answers

Github does not host nodejs instances.

like image 119
Adam Gent Avatar answered Oct 10 '22 13:10

Adam Gent


If you want to host a it on GitHub pages you can follow these steps:

  1. Separate Angular front end with node back end API.
  2. Host your Angular front end to GitHub pages.
  3. Then host your node back end to some cloud hosting. Make sure you have CORS enabled. It will work as a REST API.
  4. Now use the REST API end points to wire up the the whole app.
like image 33
Razat Patkar Avatar answered Oct 10 '22 13:10

Razat Patkar