Reactjs Can';在react+;中刷新页面时未找到URL;react路由器&x2B;express+;网页包

Reactjs Can';在react+;中刷新页面时未找到URL;react路由器&x2B;express+;网页包,reactjs,express,webpack-dev-server,react-router-v4,webpack-3,Reactjs,Express,Webpack Dev Server,React Router V4,Webpack 3,我对路由器、快递和其他东西不熟悉。我一直在遵循一些教程,关于如何防止在react应用程序中刷新页面时出现“无法获取URL” 我找到了很多关于这个问题的相关问答话题,并尝试了一下。但不幸的是。。它失败了。可能是因为我现在使用的网页已经升级到v3.5.5 我尝试使用webpack dev server,并将historyApiFallback属性放在webpack配置文件的devServer对象中。这也是一次失败 因此,我将在下面提供一些配置文件。请检查并告诉我我做错了什么或我应该做什么 1) we

我对路由器、快递和其他东西不熟悉。我一直在遵循一些教程,关于如何防止在react应用程序中刷新页面时出现“无法获取URL”

我找到了很多关于这个问题的相关问答话题,并尝试了一下。但不幸的是。。它失败了。可能是因为我现在使用的网页已经升级到
v3.5.5

我尝试使用
webpack dev server
,并将historyApiFallback属性放在webpack配置文件的devServer对象中。这也是一次失败

因此,我将在下面提供一些配置文件。请检查并告诉我我做错了什么或我应该做什么

1) webpack.config.js

const path = require('path');

module.exports = {
  entry: './client/src/index.jsx',
  output: {
    path: path.resolve(__dirname, '/client/dist/js'),
    filename: 'app.js',
    publicPath: './client/dist/js'
  },
  devServer: {
    historyApiFallback: {
      index: path.resolve(__dirname, './server/static/index.html'),
    }
  },
  module: {
    rules: [
      {
        test: /\.jsx?$/,
        include: path.join(__dirname, '/client/src'),
        use: 'babel-loader',
        query: {
          presets: ["react", "es2015"],
          plugins: ["transform-class-properties"]
        }
      },
      {
        test: /\.css$/,
        loader: 'style-loader!css-loader'
      }
    ]
  }
};
2) index.js/server文件

const express = require('express');
const bodyParser = require('body-parser');
const passport = require('passport');
const config = require('./config');

// connect to the database and load models
require('./server/models').connect(config.dbUri);

const app = express();

// tell the app to look for static files in these directories
app.use(express.static('./server/static/'));
app.use(express.static('./client/dist/'));

// tell the app to parse HTTP body messages
app.use(bodyParser.urlencoded({ extended: false }));

// pass the passport middleware
app.use(passport.initialize());

// load passport strategies
const localSignupStrategy = require('./server/passport/local-signup');
const localLoginStrategy = require('./server/passport/local-login');
passport.use('local-signup', localSignupStrategy);
passport.use('local-login', localLoginStrategy);

// pass the authenticaion checker middleware
const authCheckMiddleware = require('./server/middleware/auth-check');
app.use('/api', authCheckMiddleware);

// routes
const authRoutes = require('./server/routes/auth');
const apiRoutes = require('./server/routes/api');
app.use('/auth', authRoutes);
app.use('/api', apiRoutes);

// start the server
app.listen(3000, () => {
  console.log('Server is running on http://localhost:3000');
});
3) package.json

{
  "name": "example-app",
  "version": "1.0.0",
  "description": "Example App",
  "main": "index.js",
  "scripts": {
    "start": "nodemon --use_strict index.js",
    "bundle": "webpack"
  },
  "license": "ISC",
  "dependencies": {
    "bcrypt": "^1.0.2",
    "body-parser": "^1.17.2",
    "bootstrap": "^4.0.0-alpha.6",
    "express": "^4.15.4",
    "jsonwebtoken": "^7.4.3",
    "material-ui": "^0.19.0",
    "mongoose": "^4.11.7",
    "passport": "^0.4.0",
    "passport-local": "^1.0.0",
    "react": "^15.6.1",
    "react-addons-css-transition-group": "^15.6.0",
    "react-addons-transition-group": "^15.6.0",
    "react-dom": "^15.6.1",
    "react-router-dom": "^4.2.2",
    "react-tap-event-plugin": "^2.0.1",
    "reactstrap": "^4.8.0",
    "validator": "^8.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "clean-webpack-plugin": "^0.1.16",
    "css-loader": "^0.28.5",
    "file-loader": "^0.11.2",
    "html-webpack-plugin": "^2.30.1",
    "nodemon": "^1.11.0",
    "style-loader": "^0.18.2",
    "url-loader": "^0.5.9",
    "webpack": "^3.5.5",
    "webpack-dev-server": "^2.7.1"
  }
}

您正在尝试使用devserver和您自己的express服务器吗@是的。我是从网上的一些教程中得到的。