What to do if react cannot be accessed during startup

藏色散人
Release: 2023-01-04 10:33:21
Original
2418 people have browsed it

Solutions to the inaccessibility of react startup: 1. Install "http-proxy-middleware"; 2. Find "setupProxy.js" and delete it directly; 3. Create a new project and restart the project.

What to do if react cannot be accessed during startup

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What should I do if the react startup cannot be accessed?

The react project startup shows that the local connection has been refused

It’s a very strange problem. I could use it normally the day before, and then opened the computer to start the project the next day A problem occurred.

The solution for react project startup showing that the local connection has been refused was not found on Baidu

You can connect normally by going back to the previous version through the git version

There was really nothing I could do at the beginning, so I continued writing from the previous version.

As a result, there was a version conflict. After I solved it manually, I started the project again.

The local connection was refused again...

I was so angry and numb at the time

I couldn’t find a way to do it anymore, so I had to use stupid methods

to create a new project and make sure that the new project could be started.

Moved the original project files one by one

Finally I successfully found the culprit

What to do if react cannot be accessed during startup

This thing is used as a proxy Yes, just delete this thing and you can start it normally, but not vice versa

The problem lies here

There are several ways to write this because of version issues

Put it here The version I can use normally

const { createProxyMiddleware } = require('http-proxy-middleware') module.exports = function (app) { app.use(createProxyMiddleware('/api', { target: 'http://106.14.82.240:3000', secure: false, changeOrigin: true, pathRewrite: { "^/api": "/api" } })) }
Copy after login

Also remember to install http-proxy-middleware

Recommended learning: "react video tutorial"

The above is the detailed content of What to do if react cannot be accessed during startup. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!