Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to debug Mini Program locally

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to debug Mini Program locally". In daily operation, I believe many people have doubts about how to debug Mini Program locally. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about "how to debug Mini Program locally". Next, please follow the editor to study!

First of all, for those who do not need to call the necessary appid functions such as user login, we can directly create the project without entering appid, so that Mini Program is not restricted by the legitimate domain name and can directly access the backend within our LAN.

For api such as user login and WeChat Pay, you must have appid and go through Tencent's server. At this time, we must make our backend accessible to the public network, and in the legitimate domain name configuration, it can only be https. Generally speaking, when we are developing, we must have already bought a public network server (such as Aliyun ecs), and configuration is not the focus of this article. This article assumes that you already have an ecs, filing, ssl certificate and so on. Here are several options:

Directly use the public network server

In the regular process, the background code is deployed to the server, and then Mini Program debugging. As mentioned above, the shortcomings are obvious. But if your needs are clear, you can finish it quickly in the background, and you don't need to revise it often, you can do so. I think you can configure git on the server and host the code directly to the server, or if the code is on a platform such as Code Cloud, you can use git pull on the server, and then run the code directly on the server, and then package and run it when the background is stable. I think it's better to do this, because each package takes a lot of time. Of course, forget it with docker or something like that.

Use some intranet penetration tools

I have used some before, ngrok, ittun (based on ngrok), localtunel (nodejs) have all been used. The advantage is that it is more convenient and does not need too much configuration, but the disadvantages are also very detailed and unstable. You can also build your own ngrok.

Forward to the local server through the public network server (recommended)

I have used this method recently, and it feels very good, stable and fast, but my server is centos. I don't know if there is anything similar on win server.

First, turn on the remote forwarding function of the server, add a sentence at the end of the / etc/ssh/sshd_config file: GatewayPorts yes, and then restart ssh:sudo systemctl restart sshd.

Then xshell is installed in the local environment, which is forwarded with its tunneling function. Specifically, add a forwarding rule in the properties > connection > ssh > tunnel, such as forwarding port 80 on the server to port 80 locally.

Restart xshell, and when xshell connects to the server, the request from the server to port 80 can be forwarded to the local port 80.

Location / admin/ {

Proxy_pass https://localhost/admin/;

}

Location / image/ {

Proxy_pass https://localhost/image/;

}

Location / api/ {

Proxy_pass https://localhost/api/;

}

This configuration is more targeted, for example, admin is the administrator background API, which is called to the web side, image is the image path, and api is called to Mini Program. Of course, you can also forward all of them directly:

Location / {

Proxy_pass https://localhost;

}

Or you have a running version that is already running on the server, and you need to configure another one for development. You can do this:

Location / dev/ {

Proxy_pass https://localhost/;

}

Of course, the reason is the same, you can even configure ssl on only one server, and then configure different forwarding paths for different backends, so that other backends do not need ssl, as long as the server load is not a problem.

At this point, the study of "how to debug Mini Program locally" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report