diff options
| author | nsfisis <nsfisis@gmail.com> | 2024-08-10 00:14:17 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2024-08-10 00:14:17 +0900 |
| commit | b450648caa0d1bd5c91e67a33153bbacaf57f006 (patch) | |
| tree | 8dce01b8eb398759a3abdb97d3d333b52738c768 | |
| parent | a7342525e5e4052113e6d5e75b6fd50c91687514 (diff) | |
| download | iosdc-japan-2024-albatross-b450648caa0d1bd5c91e67a33153bbacaf57f006.tar.gz iosdc-japan-2024-albatross-b450648caa0d1bd5c91e67a33153bbacaf57f006.tar.zst iosdc-japan-2024-albatross-b450648caa0d1bd5c91e67a33153bbacaf57f006.zip | |
feat: prepend base path
| -rw-r--r-- | backend/admin/handler.go | 4 | ||||
| -rw-r--r-- | backend/admin/templates/base.html | 6 | ||||
| -rw-r--r-- | backend/admin/templates/dashboard.html | 6 | ||||
| -rw-r--r-- | backend/admin/templates/game_edit.html | 2 | ||||
| -rw-r--r-- | backend/admin/templates/games.html | 4 | ||||
| -rw-r--r-- | backend/admin/templates/user_edit.html | 2 | ||||
| -rw-r--r-- | backend/admin/templates/users.html | 4 | ||||
| -rw-r--r-- | backend/main.go | 12 | ||||
| -rw-r--r-- | docs/DEV.md | 2 | ||||
| -rw-r--r-- | frontend/app/.server/api/client.ts | 4 | ||||
| -rw-r--r-- | frontend/app/components/GolfPlayApp.client.tsx | 5 | ||||
| -rw-r--r-- | frontend/app/components/GolfWatchApp.client.tsx | 5 | ||||
| -rw-r--r-- | frontend/app/routes/dashboard.tsx | 4 | ||||
| -rw-r--r-- | frontend/vite.config.ts | 1 | ||||
| -rw-r--r-- | nginx.conf | 8 |
15 files changed, 34 insertions, 35 deletions
diff --git a/backend/admin/handler.go b/backend/admin/handler.go index b50b942..7239b08 100644 --- a/backend/admin/handler.go +++ b/backend/admin/handler.go @@ -37,11 +37,11 @@ func newAdminMiddleware() echo.MiddlewareFunc { return func(c echo.Context) error { jwt, err := c.Cookie("albatross_token") if err != nil { - return c.Redirect(http.StatusSeeOther, "/login") + return c.Redirect(http.StatusSeeOther, "/iosdc-japan/2024/code-battle/login") } claims, err := auth.ParseJWT(jwt.Value) if err != nil { - return c.Redirect(http.StatusSeeOther, "/login") + return c.Redirect(http.StatusSeeOther, "/iosdc-japan/2024/code-battle/login") } if !claims.IsAdmin { return echo.NewHTTPError(http.StatusForbidden) diff --git a/backend/admin/templates/base.html b/backend/admin/templates/base.html index 4bcdbdd..49e2066 100644 --- a/backend/admin/templates/base.html +++ b/backend/admin/templates/base.html @@ -2,9 +2,9 @@ <html> <head> <title>ADMIN {{ .Title }} | iOSDC Japan 2024 Albatross.swift</title> - <link rel="icon" href="/favicon.svg"> - <link rel="stylesheet" href="/admin/css/normalize.css"> - <link rel="stylesheet" href="/admin/css/sakura.css"> + <link rel="icon" href="/iosdc-japan/2024/code-battle/favicon.svg"> + <link rel="stylesheet" href="/iosdc-japan/2024/code-battle/admin/css/normalize.css"> + <link rel="stylesheet" href="/iosdc-japan/2024/code-battle/admin/css/sakura.css"> </head> <body> <section> diff --git a/backend/admin/templates/dashboard.html b/backend/admin/templates/dashboard.html index cdb8ba1..b2037cb 100644 --- a/backend/admin/templates/dashboard.html +++ b/backend/admin/templates/dashboard.html @@ -2,12 +2,12 @@ {{ define "content" }} <p> - <a href="/admin/users">Users</a> + <a href="/iosdc-japan/2024/code-battle/admin/users">Users</a> </p> <p> - <a href="/admin/games">Games</a> + <a href="/iosdc-japan/2024/code-battle/admin/games">Games</a> </p> -<form method="post" action="/logout"> +<form method="post" action="/iosdc-japan/2024/code-battle/logout"> <button type="submit">Logout</button> </form> {{ end }} diff --git a/backend/admin/templates/game_edit.html b/backend/admin/templates/game_edit.html index 108ae99..f40cc5d 100644 --- a/backend/admin/templates/game_edit.html +++ b/backend/admin/templates/game_edit.html @@ -1,7 +1,7 @@ {{ template "base.html" . }} {{ define "breadcrumb" }} -<a href="/admin/dashboard">Dashboard</a> | <a href="/admin/games">Games</a> +<a href="/iosdc-japan/2024/code-battle/admin/dashboard">Dashboard</a> | <a href="/iosdc-japan/2024/code-battle/admin/games">Games</a> {{ end }} {{ define "content" }} diff --git a/backend/admin/templates/games.html b/backend/admin/templates/games.html index 47dc4a3..0616938 100644 --- a/backend/admin/templates/games.html +++ b/backend/admin/templates/games.html @@ -1,14 +1,14 @@ {{ template "base.html" . }} {{ define "breadcrumb" }} -<a href="/admin/dashboard">Dashboard</a> +<a href="/iosdc-japan/2024/code-battle/admin/dashboard">Dashboard</a> {{ end }} {{ define "content" }} <ul> {{ range .Games }} <li> - <a href="/admin/games/{{ .GameID }}"> + <a href="/iosdc-japan/2024/code-battle/admin/games/{{ .GameID }}"> {{ .DisplayName }} (id={{ .GameID }} type={{ .GameType }} state={{ .State }}) </a> </li> diff --git a/backend/admin/templates/user_edit.html b/backend/admin/templates/user_edit.html index bde7c84..56ecbc8 100644 --- a/backend/admin/templates/user_edit.html +++ b/backend/admin/templates/user_edit.html @@ -1,7 +1,7 @@ {{ template "base.html" . }} {{ define "breadcrumb" }} -<a href="/admin/dashboard">Dashboard</a> | <a href="/admin/users">Users</a> +<a href="/iosdc-japan/2024/code-battle/admin/dashboard">Dashboard</a> | <a href="/iosdc-japan/2024/code-battle/admin/users">Users</a> {{ end }} {{ define "content" }} diff --git a/backend/admin/templates/users.html b/backend/admin/templates/users.html index 656ad53..3543457 100644 --- a/backend/admin/templates/users.html +++ b/backend/admin/templates/users.html @@ -1,14 +1,14 @@ {{ template "base.html" . }} {{ define "breadcrumb" }} -<a href="/admin/dashboard">Dashboard</a> +<a href="/iosdc-japan/2024/code-battle/admin/dashboard">Dashboard</a> {{ end }} {{ define "content" }} <ul> {{ range .Users }} <li> - <a href="/admin/users/{{ .UserID }}"> + <a href="/iosdc-japan/2024/code-battle/admin/users/{{ .UserID }}"> {{ .DisplayName }} (id={{ .UserID }} username={{ .Username }}){{ if .IsAdmin }} <em>admin</em>{{ end }} </a> </li> diff --git a/backend/main.go b/backend/main.go index 575c3f8..c01394b 100644 --- a/backend/main.go +++ b/backend/main.go @@ -38,7 +38,7 @@ func main() { log.Fatalf("Error loading env %v", err) } - openAPISpec, err := api.GetSwaggerWithPrefix("/api") + openAPISpec, err := api.GetSwaggerWithPrefix("/iosdc-japan/2024/code-battle/api") if err != nil { log.Fatalf("Error loading OpenAPI spec\n: %s", err) } @@ -69,7 +69,7 @@ func main() { log.Fatalf("Error restoring game hubs from db %v", err) } defer gameHubs.Close() - sockGroup := e.Group("/sock") + sockGroup := e.Group("/iosdc-japan/2024/code-battle/sock") sockHandler := gameHubs.SockHandler() sockGroup.GET("/golf/:gameID/play", func(c echo.Context) error { return sockHandler.HandleSockGolfPlay(c) @@ -78,22 +78,22 @@ func main() { return sockHandler.HandleSockGolfWatch(c) }) - apiGroup := e.Group("/api") + apiGroup := e.Group("/iosdc-japan/2024/code-battle/api") apiGroup.Use(oapimiddleware.OapiRequestValidator(openAPISpec)) apiHandler := api.NewHandler(queries, gameHubs) api.RegisterHandlers(apiGroup, api.NewStrictHandler(apiHandler, nil)) adminHandler := admin.NewHandler(queries, gameHubs) - adminGroup := e.Group("/admin") + adminGroup := e.Group("/iosdc-japan/2024/code-battle/admin") adminHandler.RegisterHandlers(adminGroup) // For local dev: This is never used in production because the reverse // proxy sends /login and /logout to the app server. e.GET("/login", func(c echo.Context) error { - return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/login") + return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/iosdc-japan/2024/code-battle/login") }) e.POST("/logout", func(c echo.Context) error { - return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/logout") + return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173/iosdc-japan/2024/code-battle/logout") }) go gameHubs.Run() diff --git a/docs/DEV.md b/docs/DEV.md index fff7fbb..e91c6dc 100644 --- a/docs/DEV.md +++ b/docs/DEV.md @@ -20,7 +20,7 @@ 1. `cd path/to/the/repo` 1. `make init` 1. `make up` -1. Access to http://localhost:5173. +1. Access to http://localhost:5173/iosdc-japan/2024/code-battle/. * User `a`, `b` and `c` can log in with `pass` password. * User `a` and `b` are players. * User `c` is an administrator. diff --git a/frontend/app/.server/api/client.ts b/frontend/app/.server/api/client.ts index aae1723..1c96b7b 100644 --- a/frontend/app/.server/api/client.ts +++ b/frontend/app/.server/api/client.ts @@ -4,8 +4,8 @@ import type { paths } from "./schema"; const apiClient = createClient<paths>({ baseUrl: process.env.NODE_ENV === "development" - ? "http://localhost:8002/api/" - : "http://api-server/api/", + ? "http://localhost:8002/iosdc-japan/2024/code-battle/api/" + : "http://api-server/iosdc-japan/2024/code-battle/api/", }); export async function apiPostLogin( diff --git a/frontend/app/components/GolfPlayApp.client.tsx b/frontend/app/components/GolfPlayApp.client.tsx index 911fae0..43828e6 100644 --- a/frontend/app/components/GolfPlayApp.client.tsx +++ b/frontend/app/components/GolfPlayApp.client.tsx @@ -22,11 +22,10 @@ export default function GolfPlayApp({ game: Game; sockToken: string; }) { - // const socketUrl = `wss://t.nil.ninja/iosdc-japan/2024/sock/golf/${game.game_id}/play?token=${sockToken}`; const socketUrl = process.env.NODE_ENV === "development" - ? `ws://localhost:8002/sock/golf/${game.game_id}/play?token=${sockToken}` - : `ws://api-server/sock/golf/${game.game_id}/play?token=${sockToken}`; + ? `ws://localhost:8002/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}` + : `wss://t.nil.ninja/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/play?token=${sockToken}`; const { sendJsonMessage, lastJsonMessage, readyState } = useWebSocket<WebSocketMessage>(socketUrl, {}); diff --git a/frontend/app/components/GolfWatchApp.client.tsx b/frontend/app/components/GolfWatchApp.client.tsx index aefe945..829f709 100644 --- a/frontend/app/components/GolfWatchApp.client.tsx +++ b/frontend/app/components/GolfWatchApp.client.tsx @@ -20,11 +20,10 @@ export default function GolfWatchApp({ game: Game; sockToken: string; }) { - // const socketUrl = `wss://t.nil.ninja/iosdc-japan/2024/sock/golf/${game.game_id}/watch?token=${sockToken}`; const socketUrl = process.env.NODE_ENV === "development" - ? `ws://localhost:8002/sock/golf/${game.game_id}/watch?token=${sockToken}` - : `ws://api-server/sock/golf/${game.game_id}/watch?token=${sockToken}`; + ? `ws://localhost:8002/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}` + : `wss://t.nil.ninja/iosdc-japan/2024/code-battle/sock/golf/${game.game_id}/watch?token=${sockToken}`; const { lastJsonMessage, readyState } = useWebSocket<WebSocketMessage>( socketUrl, diff --git a/frontend/app/routes/dashboard.tsx b/frontend/app/routes/dashboard.tsx index e6a43de..d69018a 100644 --- a/frontend/app/routes/dashboard.tsx +++ b/frontend/app/routes/dashboard.tsx @@ -13,8 +13,8 @@ export async function loader({ request }: LoaderFunctionArgs) { if (user.is_admin) { return redirect( process.env.NODE_ENV === "development" - ? "http://localhost:8002/admin/dashboard" - : "/admin/dashboard", + ? "http://localhost:8002/iosdc-japan/2024/code-battle/admin/dashboard" + : "/iosdc-japan/2024/code-battle/admin/dashboard", ); } const { games } = await apiGetGames(token); diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index e07fb91..bb04554 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -10,6 +10,7 @@ export default defineConfig({ v3_relativeSplatPath: true, v3_throwAbortReason: true, }, + basename: "/iosdc-japan/2024/code-battle/", }), tsconfigPaths(), ], @@ -12,7 +12,7 @@ http { server { listen 80; - location /api/ { + location /iosdc-japan/2024/code-battle/api/ { proxy_pass http://api-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -20,7 +20,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location /admin/ { + location /iosdc-japan/2024/code-battle/admin/ { proxy_pass http://api-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; @@ -28,7 +28,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location /sock/ { + location /iosdc-japan/2024/code-battle/sock/ { proxy_pass http://api-server; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; @@ -39,7 +39,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - location / { + location /iosdc-japan/2024/code-battle/ { proxy_pass http://app-server; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; |
