Quickly build your own server in one minute
When doing mobile applications, the localhost address generated by the local server cannot be opened on the mobile side, so we also need a reverse proxy. Let's talk about how to quickly build a server of our own.
1. Local server
Local servers can be generated in many ways, using automated build tools such as grunt,glup,webpack, and so on. You can also use nodejs. Here's a general way: http-server.
Npm install-g http-server / / Global installation of http-server
one
Http-server / / run http-server
one
An address of localhost will be generated
Enter localhost:8080 in the browser to open the local page.
Of course, linux users can also use the simpler python to build.
two。 Reverse proxy
We do not choose the method of generating the public key as described on the official website. We first select the corresponding version to download to the project, then run ngrok.exe, and enter:
Ngrok http 8080 / / use the port number generated by the corresponding local server
one
A URL is generated as follows:
In this way, we can open the URL to view the page in the browser of any device.
The disadvantage of this approach is that it needs to be regenerated after each disconnect, and the address is not unique, but it is more convenient and quick for you to debug the project.