preface

I started the Antd Design Pro + Umi project and encountered the problem of Umi UI connection failure when I visited the project. After repeated research, I found out the problem and recorded it here to prevent it from being forgotten in the future.

To debug a:

  1. Click the following button

  1. The Umi UI is displayed as follows

  1. Displayed in the console

Locate the error according to the console display

Webpack: / / /. / node_modules / _sockjs – [email protected] @ sockjs – client/lib/transport/browser/abstract – XHR. Js

Modified as follows:

self.xhr.send(payload)Instead ofself.xhr.status==200 && self.xhr.send(payload)The first error can be eliminated as follows:

After the modification, the following information disappears when the project is started

But at this time, Umi UI is still connected failure, did not fundamentally solve the problem.

Debugging. 2:

According to Umi UI, non-local IP addresses are not allowed to access, and when starting the project, the default access mode is as follows:

In fact, if you open it in Local mode, this record problem will not occur; This problem occurs when NetWork access is used

So we can set Local and NetWork to the same.

The setting method is as follows:

In the root directory of the project, add a new file. env and set the parameters as follows:

The HOST = 192.168.8.79 PORT = 8000 BROWSER = noneCopy the code

Restart the YARN Start project

Visit the project and the problem is resolved

Note:

If HOST is set to 0.0.0.0, an orange prompt will appear at the top of the project after it is started, as follows:

Umi UI connection failure also occurs.