mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
fix: cannot ota upgrade when connect to remote node #424
This commit is contained in:
parent
f41b6bc07b
commit
7ef4fec896
8 changed files with 115 additions and 156 deletions
|
@ -13,5 +13,8 @@ func InitPublicRouter(r *gin.RouterGroup) {
|
||||||
func InitPrivateRouter(r *gin.RouterGroup) {
|
func InitPrivateRouter(r *gin.RouterGroup) {
|
||||||
r.GET("upgrade/release", GetRelease)
|
r.GET("upgrade/release", GetRelease)
|
||||||
r.GET("upgrade/current", GetCurrentVersion)
|
r.GET("upgrade/current", GetCurrentVersion)
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitWebSocketRouter(r *gin.RouterGroup) {
|
||||||
r.GET("upgrade/perform", PerformCoreUpgrade)
|
r.GET("upgrade/perform", PerformCoreUpgrade)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,3 +21,47 @@ manual `h(...)` calls), you can enable Volar's Take Over mode by following these
|
||||||
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
2. Reload the VS Code window by running `Developer: Reload Window` from the command palette.
|
||||||
|
|
||||||
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
You can learn more about Take Over mode [here](https://github.com/johnsoncodehk/volar/discussions/471).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** The default target of the api proxy is `http://localhost:9000`,
|
||||||
|
if you need to change this, create the `.env` file in root directory and set your target in it.
|
||||||
|
|
||||||
|
```env
|
||||||
|
VITE_PROXY_TARGET=http://localhost:9001
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm dev
|
||||||
|
```
|
||||||
|
|
||||||
|
**Note:** The default port of the dev server is `3002`,
|
||||||
|
if you need to change this, create the `.env` file in root directory and set your port in it.
|
||||||
|
|
||||||
|
```env
|
||||||
|
VITE_PORT=3456
|
||||||
|
```
|
||||||
|
|
||||||
|
### Code Style Check
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm lint
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type Check
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm typecheck
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm build
|
||||||
|
```
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"version":"2.0.0-beta.26","build_id":141,"total_build":345}
|
{"version":"2.0.0-beta.26","build_id":142,"total_build":346}
|
|
@ -1 +1 @@
|
||||||
{"version":"2.0.0-beta.26","build_id":141,"total_build":345}
|
{"version":"2.0.0-beta.26","build_id":142,"total_build":346}
|
|
@ -71,6 +71,7 @@ export default defineConfig(({ mode }) => {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
|
port: Number.parseInt(env.VITE_PORT) || 3002,
|
||||||
proxy: {
|
proxy: {
|
||||||
'/api': {
|
'/api': {
|
||||||
target: env.VITE_PROXY_TARGET || 'http://localhost:9000',
|
target: env.VITE_PROXY_TARGET || 'http://localhost:9000',
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -65,9 +65,7 @@ func (e *Environment) GetWebSocketURL(uri string) (decodedUri string, err error)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// http will be replaced with ws, https will be replaced with wss
|
// http will be replaced with ws, https will be replaced with wss
|
||||||
decodedUri = strings.ReplaceAll(decodedUri, "http", "ws")
|
decodedUri = strings.ReplaceAll(decodedUri, "http", "ws")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,79 +1,79 @@
|
||||||
package router
|
package router
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/0xJacky/Nginx-UI/api/analytic"
|
"github.com/0xJacky/Nginx-UI/api/analytic"
|
||||||
"github.com/0xJacky/Nginx-UI/api/certificate"
|
"github.com/0xJacky/Nginx-UI/api/certificate"
|
||||||
"github.com/0xJacky/Nginx-UI/api/cluster"
|
"github.com/0xJacky/Nginx-UI/api/cluster"
|
||||||
"github.com/0xJacky/Nginx-UI/api/config"
|
"github.com/0xJacky/Nginx-UI/api/config"
|
||||||
"github.com/0xJacky/Nginx-UI/api/nginx"
|
"github.com/0xJacky/Nginx-UI/api/nginx"
|
||||||
"github.com/0xJacky/Nginx-UI/api/notification"
|
"github.com/0xJacky/Nginx-UI/api/notification"
|
||||||
"github.com/0xJacky/Nginx-UI/api/openai"
|
"github.com/0xJacky/Nginx-UI/api/openai"
|
||||||
"github.com/0xJacky/Nginx-UI/api/settings"
|
"github.com/0xJacky/Nginx-UI/api/settings"
|
||||||
"github.com/0xJacky/Nginx-UI/api/sites"
|
"github.com/0xJacky/Nginx-UI/api/sites"
|
||||||
"github.com/0xJacky/Nginx-UI/api/streams"
|
"github.com/0xJacky/Nginx-UI/api/streams"
|
||||||
"github.com/0xJacky/Nginx-UI/api/system"
|
"github.com/0xJacky/Nginx-UI/api/system"
|
||||||
"github.com/0xJacky/Nginx-UI/api/template"
|
"github.com/0xJacky/Nginx-UI/api/template"
|
||||||
"github.com/0xJacky/Nginx-UI/api/terminal"
|
"github.com/0xJacky/Nginx-UI/api/terminal"
|
||||||
"github.com/0xJacky/Nginx-UI/api/upstream"
|
"github.com/0xJacky/Nginx-UI/api/upstream"
|
||||||
"github.com/0xJacky/Nginx-UI/api/user"
|
"github.com/0xJacky/Nginx-UI/api/user"
|
||||||
"github.com/gin-contrib/static"
|
"github.com/gin-contrib/static"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitRouter() *gin.Engine {
|
func InitRouter() *gin.Engine {
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
r.Use(gin.Logger())
|
r.Use(gin.Logger())
|
||||||
r.Use(recovery())
|
r.Use(recovery())
|
||||||
r.Use(cacheJs())
|
r.Use(cacheJs())
|
||||||
r.Use(ipWhiteList())
|
r.Use(ipWhiteList())
|
||||||
|
|
||||||
//r.Use(OperationSync())
|
//r.Use(OperationSync())
|
||||||
|
|
||||||
r.Use(static.Serve("/", mustFS("")))
|
r.Use(static.Serve("/", mustFS("")))
|
||||||
|
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.JSON(http.StatusNotFound, gin.H{
|
c.JSON(http.StatusNotFound, gin.H{
|
||||||
"message": "not found",
|
"message": "not found",
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
root := r.Group("/api")
|
root := r.Group("/api")
|
||||||
{
|
{
|
||||||
system.InitPublicRouter(root)
|
system.InitPublicRouter(root)
|
||||||
user.InitAuthRouter(root)
|
user.InitAuthRouter(root)
|
||||||
|
|
||||||
// Authorization required not websocket request
|
// Authorization required not websocket request
|
||||||
g := root.Group("/", authRequired(), proxy())
|
g := root.Group("/", authRequired(), proxy())
|
||||||
{
|
{
|
||||||
analytic.InitRouter(g)
|
analytic.InitRouter(g)
|
||||||
user.InitManageUserRouter(g)
|
user.InitManageUserRouter(g)
|
||||||
nginx.InitRouter(g)
|
nginx.InitRouter(g)
|
||||||
sites.InitRouter(g)
|
sites.InitRouter(g)
|
||||||
streams.InitRouter(g)
|
streams.InitRouter(g)
|
||||||
config.InitRouter(g)
|
config.InitRouter(g)
|
||||||
template.InitRouter(g)
|
template.InitRouter(g)
|
||||||
certificate.InitCertificateRouter(g)
|
certificate.InitCertificateRouter(g)
|
||||||
certificate.InitDNSCredentialRouter(g)
|
certificate.InitDNSCredentialRouter(g)
|
||||||
certificate.InitAcmeUserRouter(g)
|
certificate.InitAcmeUserRouter(g)
|
||||||
system.InitPrivateRouter(g)
|
system.InitPrivateRouter(g)
|
||||||
settings.InitRouter(g)
|
settings.InitRouter(g)
|
||||||
openai.InitRouter(g)
|
openai.InitRouter(g)
|
||||||
cluster.InitRouter(g)
|
cluster.InitRouter(g)
|
||||||
notification.InitRouter(g)
|
notification.InitRouter(g)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authorization required and websocket request
|
// Authorization required and websocket request
|
||||||
w := root.Group("/", authRequired(), proxyWs())
|
w := root.Group("/", authRequired(), proxyWs())
|
||||||
{
|
{
|
||||||
analytic.InitWebSocketRouter(w)
|
analytic.InitWebSocketRouter(w)
|
||||||
certificate.InitCertificateWebSocketRouter(w)
|
certificate.InitCertificateWebSocketRouter(w)
|
||||||
terminal.InitRouter(w)
|
terminal.InitRouter(w)
|
||||||
nginx.InitNginxLogRouter(w)
|
nginx.InitNginxLogRouter(w)
|
||||||
upstream.InitRouter(w)
|
upstream.InitRouter(w)
|
||||||
}
|
system.InitWebSocketRouter(w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
return r
|
||||||
|
|
||||||
return r
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue