简体   繁体   English

react-boilerplate yarn start:prod无法访问此站点,本地主机拒绝连接。 http:// localhost:3000 => https:// localhost /

[英]react-boilerplate yarn start:prod This site can’t be reached localhost refused to connect. http://localhost:3000 => https://localhost/

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

Description 描述

After running yarn run build, yarn start:prod It says it is running on the terminal window, however, when i go to http://localhost:3000 the url suddenly changes to => https://localhost/ and says this site can't be reached localhost refused to connect. 运行yarn run build之后,yarn start:prod它说它正在终端窗口上运行,但是,当我转到http:// localhost:3000时 ,URL突然变为=> https:// localhost /并说此站点无法访问localhost拒绝连接。

development mode yarn start works fine 开发模式纱线启动正常

Steps to reproduce 重现步骤

I removed ImmutableJS following the guide from one of the issues in react-boilerplate. 我按照指南从React-Boilerplate中的问题之一删除了ImmutableJS。

I added feathersJS backend, frontend. 我添加了feathersJS后端,前端。

I changed babel-loader in webpack.base.babel.js to 我将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" }]
       ],
     },
    },
  },

I changed the app.js file 我更改了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');
    }
  });
}

Much appreciate your help! 非常感谢您的帮助!

(Add link to a demo on https://jsfiddle.net or similar if possible) (如果可能,在https://jsfiddle.net或类似网站上添加指向演示的链接)

Versions 版本

  • React-Boilerplate (see package.json ): 3.6.0 React-Boilerplate(请参阅package.json ):3.6.0
  • Node/NPM: v9.11.1 节点/ NPM:v9.11.1
  • Browser: chrome 浏览器:chrome

I forgot I was using ssl-redirect for heroku deployment. 我忘记了我使用ssl-redirect进行heroku部署。

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

cheers :) 欢呼:)

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

相关问题 与grapejs一起使用-是否“启动了npm”,但是localhost:8080将说无法访问此站点localhost拒绝连接 - with grapejs - did “npm start”, but localhost:8080 will say This site can’t be reached localhost refused to connect Node & React - npm start - 正在运行但 localhost:3000 “无法访问” - Node & React - npm start - is running BUT localhost:3000 “cant be reached” localhost:3000 在使用 npm start 时拒绝连接 - localhost:3000 refused to connect when using npm start (7) 连接localhost 3000端口失败:连接被拒绝 - (7) Failed to connect to localhost port 3000: Connection refused 无法启动“curl:localhost:3000”端口,显示 URI 错误 - Can't start a "curl:localhost:3000" port, shows URI Error React fetch('http:// localhost:3000 / profile /:id') - React fetch('http://localhost:3000/profile/:id') npm start 什么都不做 / localhost:3000 连接被拒绝 - npm start does nothing / localhost:3000 connection refused 在本地主机上启动 node.js 页面 - 无法访问该站点 - starting a node.js page on localhost - the site can't be reached http://localhost:3000/api/users net::ERR_CONNECTION_REFUSED - http://localhost:3000/api/users net::ERR_CONNECTION_REFUSED 终端卷曲:(7)无法连接到localhost端口3000:连接被拒绝 - Terminal curl: (7) Failed to connect to localhost port 3000: Connection refused
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM