简体   繁体   English

在 Heroku 问题上部署平均堆栈应用程序

[英]Deploying Mean Stack Application on Heroku Issue

This is my first time building a MEAN stack application and I built it locally.这是我第一次构建 MEAN 堆栈应用程序,并且是在本地构建的。 Now I am trying to host it on heroku and I think I messed it up.现在我试图将它托管在 heroku 上,我想我把它搞砸了。 I went through different questions here and most of them said both angular and express needs to be in one single app.我在这里遇到了不同的问题,其中大多数人说 angular 和 express 都需要在一个应用程序中。 I din't know that, So here's my current folder structure.我不知道,所以这是我当前的文件夹结构。

Project Root Folder
|
| 
|------ Frontend (Angular App)
|
|
|------- Backend (Express App)

I tried searching everywhere but couldn't figure out what changes I need to make to my current project structure.我尝试到处搜索,但无法弄清楚我需要对当前项目结构进行哪些更改。 Any tips or help or even a link to a guide would be much appreciated.任何提示或帮助,甚至是指南的链接都将不胜感激。

For hosting as a single app作为单个应用程序托管

  1. first build the angular app首先构建 angular 应用程序
  2. host the build folder of front end in the backend express app as将前端的构建文件夹托管在后端快速应用程序中

app.use('*', express.static('Frontend/build/'))

  1. in start script of backend build the angular app and start the server file( index.js )在后端的启动脚本中构建 angular 应用程序并启动服务器文件( index.js
  2. inside the server file use port from the environment variables, heroku will automatically assign you with an port which will be pointed to the dynamos url在服务器文件中使用环境变量中的端口,heroku 将自动为您分配一个端口,该端口将指向发电机 url

you acn also follow this article你acn也关注这篇文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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