% npm install -g create-react app
+ create-react@0.0.0
+ app@0.1.0
added 54 packages from 28 contributors in 4.411s
% create-react-app sample-axios
Creating a new React app in /Users/nubiform/react/sample-axios.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...
> fsevents@1.2.13 install /Users/nubiform/react/sample-axios/node_modules/jest-haste-map/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> fsevents@1.2.13 install /Users/nubiform/react/sample-axios/node_modules/watchpack-chokidar2/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> fsevents@1.2.13 install /Users/nubiform/react/sample-axios/node_modules/webpack-dev-server/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> core-js@2.6.11 postinstall /Users/nubiform/react/sample-axios/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.6.5 postinstall /Users/nubiform/react/sample-axios/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js-pure@3.6.5 postinstall /Users/nubiform/react/sample-axios/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"
+ react@16.13.1
+ cra-template@1.0.3
+ react-dom@16.13.1
+ react-scripts@3.4.3
added 1605 packages from 757 contributors and audited 1605 packages in 50.387s
69 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Initialized a git repository.
Installing template dependencies using npm...
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
+ @testing-library/user-event@7.2.1
+ @testing-library/react@9.5.0
+ @testing-library/jest-dom@4.2.4
added 36 packages from 57 contributors and audited 1641 packages in 11.268s
69 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Removing template package using npm...
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
removed 1 package and audited 1640 packages in 7.191s
69 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Created git commit.
Success! Created sample-axios at /Users/nubiform/react/sample-axios
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd sample-axios
npm start
Happy hacking!
% npm i axios
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
+ axios@0.20.0
added 1 package from 1 contributor and audited 1641 packages in 7.062s
69 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
% npm i http-proxy-middleware
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
+ http-proxy-middleware@1.0.5
added 7 packages from 24 contributors, updated 1 package and audited 1648 packages in 8.292s
69 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
const { createProxyMiddleware } = require('http-proxy-middleware');
module.exports = function(app) {
app.use(
'/api',
createProxyMiddleware({
target: 'http://localhost:8081',
changeOrigin: true,
})
);
};