P
P
PlasterTom2018-04-12 18:46:52
React
PlasterTom, 2018-04-12 18:46:52

How to redirect to localhost:3000?

Good afternoon. I'm currently taking a course in React. Need to point connected api and dev server to the same port.
The api is currently opened on localhost:3001.
The link localhost:3001/api/article provides a list of articles.
On localhost:3000 our application.
It is necessary that the same list of articles be available at the link localhost:3000/api/article, that is, a redirect to localhost:3001/api/article takes place.
In the lesson, it was suggested to write in the webpack config:

devServer: {
        proxy: [{
            path: '/api/',
            target: 'http://localhost:3001'
        }],
        historyApiFallback: true
    },

But this option doesn't work for me. Maybe some additional settings are needed? Unlike the tutorial, I use create-react-app with eject made (and therefore, by the way, the webpack config is not one, but several webpack.config.dev.js, webpack.config.prod.js, webpackDevServer.config.js )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaly, 2018-04-12
@PlasterTom

https://github.com/facebook/create-react-app/blob/...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question