node.js - react-boilerplate yarn start:prod 无法访问此站点 localhost 拒绝连接。http://localhost:3000 => https://localhost/
问题描述
https://github.com/react-boilerplate/react-boilerplate
描述
运行 yarn run build 后, yarn start:prod 它说它正在终端窗口上运行,但是,当我转到http://localhost:3000 时,url 突然变为 => https://localhost/ 并说 this site无法访问 localhost 拒绝连接。
开发模式 yarn start 工作正常
重现步骤
我按照 react-boilerplate 中的问题之一的指南删除了 ImmutableJS。
我添加了feathersJS 后端、前端。
我将 webpack.base.babel.js 中的 babel-loader 更改为
rules: [
{
test: /\.js$/, // Transform all .js files required somewhere with Babel
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: options.babelQuery,
query: {
plugins: [
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": "css" }]
],
},
},
},
我更改了 app.js 文件
// Install ServiceWorker and AppCache in the end since
// it's not most important operation and if main code fails,
// we do not want it installed
if (process.env.NODE_ENV === 'production') {
// require('offline-plugin/runtime').install(); // eslint-disable-line global-require
const runtime = require('offline-plugin/runtime');
runtime.install({
onUpdating: () => {
console.log('SW Event:', 'onUpdating');
},
onUpdateReady: () => {
console.log('SW Event:', 'onUpdateReady');
// Tells to new SW to take control immediately
runtime.applyUpdate();
},
onUpdated: () => {
console.log('SW Event:', 'onUpdated');
// Reload the webpage to load into the new version
window.location.reload();
},
onUpdateFailed: () => {
console.log('SW Event:', 'onUpdateFailed');
}
});
}
非常感谢您的帮助!
(如果可能,在https://jsfiddle.net或类似网站上添加演示链接)
版本
- React-Boilerplate(见
package.json
):3.6.0 - 节点/NPM:v9.11.1
- 浏览器:铬
解决方案
我忘记了我正在使用 ssl-redirect 进行 heroku 部署。
var sslRedirect = require('heroku-ssl-redirect');
// heroku enable ssl redirect
app.use(sslRedirect()); //heroku https
干杯:)
推荐阅读
- r - 在R中迭代地解决数据框
- math - 根据朝向向前移动玩家的公式/数学计算
- selenium - 如何使用 Java 单击 Selenium 中每个菜单的子链接
- python-2.7 - 安装熊猫时出错
- ruby-on-rails - Rails - 如何删除哈希中的最后一个逗号
- python - 如何获得此组合列表?
- python - Gunicorn 通过导致 404 导致 Flask 的 add_url_rule
- java - 如何在 jGrasp 中查看类的 javadoc?
- python - 未解决的参考 pycharm 无法识别其下的类
- php - PHP Socket 服务器中的数据库连接