【问题标题】:react-boilerplate yarn start:prod This site can’t be reached localhost refused to connect. http://localhost:3000 => https://localhost/react-boilerplate yarn start:prod 无法访问此站点 localhost 拒绝连接。 http://localhost:3000 => https://localhost/
【发布时间】:2019-03-31 10:23:51
【问题描述】:

https://github.com/react-boilerplate/react-boilerplate

说明

运行 yarn run build 后, 纱线开始:产品 它说它正在终端窗口上运行,但是, 当我转到 http://localhost:3000 时,网址突然变为 => https://localhost/ 并说 无法访问此站点 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
  • 浏览器:chrome

【问题讨论】:

    标签: node.js reactjs webpack feathersjs react-boilerplate


    【解决方案1】:

    我忘记了我在使用 ssl-redirect 进行 heroku 部署。

    var sslRedirect = require('heroku-ssl-redirect');
    // heroku enable ssl redirect
    app.use(sslRedirect()); //heroku https
    

    干杯:)

    【讨论】:

      猜你喜欢
      • 2017-04-04
      • 2023-02-05
      • 2021-09-25
      • 2021-04-21
      • 2010-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-09
      相关资源
      最近更新 更多