无论我是否包含Procfile,我都会让heroku在web进程上启动"npm start“。我正在使用React/Redux构建一个简单的页面,并使用webpack进行捆绑。
实际上我的项目结构是:
/projectName
/public -->folder create during bundling with bundle.js and new html file
/src --> contains React and Redux components
.babelrc
.gitignore
index.html -->original html
我遇到的问题是,我在Heroku上托管的React应用程序调用了"“,因为它调用了Express服务器。
我将proxy in package.json设置为https://localhost:8000,以调用我的快速服务器。据我理解,这是我需要做的全部工作,Heroku在部署连接时处理它。
当我转到我的端点时,比如:https://heroku-app.herokuapp.com/v1/products/:productid我的快速服务器成功地在浏览器中发送回JSON数据,所以我知道我的节点服务器已经在Heroku上运行。问题似乎在于React应用程序proxy没有调用Heroku后
我使用Express后端的React应用程序托管在Heroku上,所有路由都按照预期工作,直到页面刷新。以编程方式刷新页面,或者使用刷新按钮返回:
Failed to load resource: the server responded with a status of 404 (Not Found)
“后退”和“前进”按钮(在刷新前工作)停止工作,使应用程序返回的唯一方法是导航到"/“。直到下一次刷新时,一切都会正常工作。
我的服务器路线:
router.use("/api/skus", skuRoutes);
router.use("/api/catego
我是Heroku的新手,我正在尝试部署我的节点服务器和create-react-app前端应用程序。一切都在本地运行得很好,但是当我尝试在Heroku上运行它时,一切都失败了。我没有收到部署错误,而且我只在我的URL上看到了Cannot GET /。
我的日志上写着:
Something is already running on port 12345
/server/app.js
var express = require('express');
var app = express();
require('dotenv').config();
var mong
我的react-app在我的本地主机服务器上工作得很好,我试着把它部署到Heroku上。然而,当我转到我从Heroku得到的应用程序地址时,我遇到了一个空白页面。没有任何组件或任何内容被渲染。你知道为什么吗?我会在下面发布我的server.js和App.js,或者如果我可以发布任何其他东西来帮助解决这个问题,请让我知道。我只是链接了一些错误的东西,所以组件没有包含在我的构建index.html中,还是发生了其他事情?
import React from 'react';
import {BrowserRouter as Router, Route, Switch} from
在试图使用Node.js显示html页面时,我得到了一个错误。我在下面提供错误。
TypeError: path must be absolute or specify root to res.sendFile
at ServerResponse.sendFile (/opt/lampp/htdocs/heroku/FGDP/node_modules/express/lib/response.js:404:11)
at /opt/lampp/htdocs/heroku/FGDP/server.js:40:6
at Layer.handle [as handle_request