Маршрутизация перестает работать на Prod реагировать + узел - PullRequest
0 голосов
/ 09 декабря 2018

После npm run build клиент перестает перенаправлять на определенные страницы (/about, /home после успешного входа в систему и т. Д.).

Однако во время разработки каждый этап проходит успешно.

Структура проекта: --client --build --src --containers --App.js index.js --other dev stuff --server --server.js --routes --svrRoutes.js --other stuff

App.js

import React, { Component } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';

class App extends Component {

    constructor(props) {
        //
    }

    render() {
        return (
            <div>
                <Router>
                    <Switch>
                        <Route path="/" exact component={Login} />
                        <Route path="/dashboard" component={withAuthentication(Dashboard)} />
                        <Route path="/about" component={About} />
                        <Route path="/home" component={withAuthentication(Home)} />
                        <Route path="/searchtweets" component={SearchTweets} />

                    </Switch>
                </Router>
                <Footer1/>
            </div>
        );
    }
}

export default App;

svrRoutes.js

let {
    addNewData,
    getData,
    getDataByID,
    updateDataByID,
    deleteDataByID,
    addNewUser,
    getUserByID,
    getUser,
    updateUserByID,
    getDataByManID
} = require('../controllers/svrController');

let {
    getTweetData
} = require('../twitter');

const routes = (app) => {


    app.route('/data')
        .get((req, res, next) => {
            // middleware
            console.log(`Request from: ${req.originalUrl}`);
            console.log(`Request type: ${req.method}`);
            next();
        }, getData)

        // POST endpoint
        .post(addNewData);

    app.route('/data/twitter')
        .get((req, res) => {
            getTweetData(req, res);
        });

    app.route('/data/:dataId')
        // get specific data Item
        .get(getDataByID)
        // put request
        .put(updateDataByID)
        // delete request
        .delete(deleteDataByID);

    app.get('/getdata', getDataByManID);

    app.route('/user')
        .post(addNewUser)

        .get((req, res, next) => {
            // middleware
            console.log(`Request from: ${req.originalUrl}`);
            console.log(`Request type: ${req.method}`);
            next();
        }, getUser);
    app.route('/user/:userId')
        .get(getUserByID)
    // put request
        .put(updateUserByID);
    app.route('/man/:userId')
        .get(getDataByManID);
};

module.exports = routes;

Вот репо на GitHub, я полагаюэто лучше, чем просто публиковать фрагменты, потому что я могу пропустить что-то важное.https://github.com/aaronjohn2/EmployerDatabaseViewApplication

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...