This commit is contained in:
yusing
2026-02-16 08:59:01 +08:00
parent 15b9635ee1
commit e4e6f6b3e8
242 changed files with 3953 additions and 3502 deletions

View File

@@ -8,7 +8,6 @@ import (
"github.com/rs/zerolog/log"
"github.com/yusing/godoxy/internal/route/rules"
"github.com/yusing/godoxy/internal/serialization"
gperr "github.com/yusing/goutils/errs"
)
//go:embed *.yml
@@ -35,12 +34,12 @@ func initPresets() {
var rules rules.Rules
content, err := fs.ReadFile(file.Name())
if err != nil {
gperr.LogError("failed to read rule preset", err)
log.Err(err).Msg("failed to read rule preset")
continue
}
_, err = serialization.ConvertString(string(content), reflect.ValueOf(&rules))
if err != nil {
gperr.LogError("failed to unmarshal rule preset", err)
log.Err(err).Msg("failed to unmarshal rule preset")
continue
}
rulePresets[file.Name()] = rules

View File

@@ -3,12 +3,19 @@
do: pass
- name: protected
on: |
!path regex("(_next/static|_next/image|favicon.ico).*")
!path glob("/api/v1/auth/*")
!path glob("/auth/*")
!path regex("[A-Za-z0-9_-]+\.(svg|png|jpg|jpeg|gif|ico|webp|woff2?|eot|ttf|otf|txt)(\?.+)?")
!path /icon0.svg
!path /favicon.ico
!path /apple-icon.png
!path glob("/web-app-manifest-*x*.png")
!path regex("\/assets\/(chunks\/)?[a-zA-Z0-9\-_]+\.(css|js|woff2)")
!path regex("\/assets\/workbox-window\.prod\.es5-[a-zA-Z0-9]+\.js")
!path regex("/workbox-[a-zA-Z0-9]+\.js")
!path /api/v1/version
!path /manifest.json
!path /sw.js
!path /registerSW.js
do: require_auth
- name: proxy to backend
on: path glob("/api/v1/*")

View File

@@ -0,0 +1,26 @@
- name: login page
on: path /login
do: pass
- name: protected
on: |
!path glob("/@tanstack-start/*")
!path glob("/@vite-plugin-pwa/*")
!path glob("/__tsd/*")
!path /@react-refresh
!path /@vite/client
!path regex("/\?token=[a-zA-Z0-9-_]+")
!path glob("/@id/*")
!path glob("/api/v1/auth/*")
!path glob("/auth/*")
!path regex("([A-Za-z0-9_\-/]+)+\.(css|ts|js|mjs|svg|png|jpg|jpeg|gif|ico|webp|woff2?|eot|ttf|otf|txt)(\?.*)?")
!path /api/v1/version
!path /manifest.json
do: require_auth
- name: proxy to backend
on: path glob("/api/v1/*")
do: proxy http://${API_ADDR}/
- name: proxy to auth api
on: path glob("/auth/*")
do: |
rewrite /auth /api/v1/auth
proxy http://${API_ADDR}/