简体   繁体   English

在部署在 heroku 上的 MERN 应用程序上获取 404

[英]Getting 404 on a MERN App deployed on heroku

I tried deploying my MERN stack app on Heroku but now I'm getting 404 when I try to launh the app.我尝试在 Heroku 上部署我的 MERN 堆栈应用程序,但现在当我尝试启动该应用程序时收到 404。 Log for the same are as follows :相同的日志如下:

2020-02-21T04:43:37.862088+00:00 heroku[router]: at=info method=GET path="/" host=task-reminder25.herokuapp.com request_id=d549deca-d280-4db4-8549-3579082e903c fwd="45.118.159.123" dyno=web.1 connect=0ms service=3ms status=404 bytes=403 protocol=https
2020-02-21T04:43:37.862479+00:00 app[web.1]: 10.63.151.139 - - [21/Feb/2020:04:43:37 +0000] "GET / HTTP/1.1" 404 191 "https://dashboard.heroku.com/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36"

I have added the Environment vaiables as well.我也添加了环境变量。 The content of my index.js(Backend) is:我的 index.js(Backend) 的内容是:

//Serve static assets in production
if(process.env.NODE_ENV==='production') {
    //Set static folder
    app.use(express.static(`../client/build`));
    app.get('*',(req,res)=>{
        res.sendFile(path.resolve(__dirname, '..','client', 'build','index.html'))
    });

} 

节点

It would be great if anyone could help me resolve this.如果有人能帮我解决这个问题,那就太好了。 Edit : I have added the link to my Github repo if anyone would like to take a look at it.编辑:如果有人想看一看,我已将链接添加到我的 Github 存储库。

try to remove nodemon if you have installed.如果您已安装,请尝试删除 nodemon。

 "scripts": {
    "start": "node app.js" // node your main file name
  },

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

相关问题 Heroku 部署的 MERN 应用程序,仅显示“未找到” - Heroku deployed MERN app, shows only “Not Found” 如何访问部署在 heroku 上的 mern 应用程序中的反应环境值? - How to access env values for react in mern app deployed on heroku? 部署在 heroku 上的节点应用程序 - 出现 404 错误(即使 url 是正确的) - Node app deployed on heroku - getting 404 error (even when url is correct) Heroku上的MERN应用 - MERN app on Heroku MERN 应用程序在部署到 Heroku 时无法运行“heroku-postbuild”脚本 - MERN app fails to run “heroku-postbuild” script while being deployed to Heroku 部署 mern 应用程序时出现 heroku 节点错误 - I'm getting heroku node errors while deploying the mern app 我正在尝试将 MERN 应用程序部署到 heroku 但出现此错误 - I am trying to deploy MERN app to heroku but getting this error Axios 在 Heroku 部署的 MERN 应用程序中未收到 cookies - Axios not receiving cookies in Heroku deployed MERN application MERN运动应用程序可在本地使用,但在部署到Heroku后无法连接到MLab - MERN exercise app works in local but cannot connect to MLab after deployed to Heroku 如何更改部署在 heroku 上的 mern 应用程序以及如何在将其部署到生产环境之前检查更改? - How to make changes to mern app deployed on heroku and how to check the changes before I deploy it in production?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM