简体   繁体   中英

Heroku - Hosting A Node API and Angular App

(Hope I'm asking this question in the right place).

a - I've built an API using NodeJS/Express.

b - I've built an website with Angular (essentially a static site) thats getting data using the API routes.

I now need to host this so have decided on Heroku to host that NodeJS API however was wondering is it possible to host that static Heroku site in the exact same location?

I can't seem to understand how it would work.

So for example, in my git root folder I have the app.js file of node that defines the routes etc however it also has the index.html . If i attempt to access any static html file or image it will run to the API rather than give those static files.

Could someone kindly explain if its possible to do/how it would fit together?

Many Thanks.

UPDATE: I found this but then would a index.html in this override everything else?: http://expressjs.com/en/starter/static-files.html

there's a good article on the heroku site about hosting a node API application on Heroku.

https://devcenter.heroku.com/articles/mean-apps-restful-api

Look (particularly) for the section 'Setup static files for the Webapp'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM