aboutsummaryrefslogtreecommitdiffhomepage
path: root/backend/main.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2024-08-18 02:05:31 +0900
committernsfisis <nsfisis@gmail.com>2024-08-18 02:05:37 +0900
commit6e405347ad218a6eb2ac1e24a6074deb41f74407 (patch)
treeff1480da8395ea677ace7cdf0c27f073bae5cbfb /backend/main.go
parente2a7c44805a3dea3790c7f4e2f9787dd9ff66102 (diff)
downloadiosdc-japan-2025-albatross-6e405347ad218a6eb2ac1e24a6074deb41f74407.tar.gz
iosdc-japan-2025-albatross-6e405347ad218a6eb2ac1e24a6074deb41f74407.tar.zst
iosdc-japan-2025-albatross-6e405347ad218a6eb2ac1e24a6074deb41f74407.zip
feat(backend): do not define local-only routes in prod env
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go36
1 files changed, 19 insertions, 17 deletions
diff --git a/backend/main.go b/backend/main.go
index 1b69bb0..7ca66ac 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -87,23 +87,25 @@ func main() {
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 directly handles /files.
- filesGroup := e.Group("/iosdc-japan/2024/code-battle/files")
- filesGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{
- Root: "/",
- Filesystem: http.Dir("/data/files"),
- IgnoreBase: true,
- }))
-
- // For local dev: This is never used in production because the reverse
- // proxy sends these paths to the app server.
- e.GET("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error {
- return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path)
- })
- e.POST("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error {
- return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path)
- })
+ if config.isLocal {
+ // For local dev: This is never used in production because the reverse
+ // proxy directly handles /files.
+ filesGroup := e.Group("/iosdc-japan/2024/code-battle/files")
+ filesGroup.Use(middleware.StaticWithConfig(middleware.StaticConfig{
+ Root: "/",
+ Filesystem: http.Dir("/data/files"),
+ IgnoreBase: true,
+ }))
+
+ // For local dev: This is never used in production because the reverse
+ // proxy sends these paths to the app server.
+ e.GET("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error {
+ return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path)
+ })
+ e.POST("/iosdc-japan/2024/code-battle/*", func(c echo.Context) error {
+ return c.Redirect(http.StatusPermanentRedirect, "http://localhost:5173"+c.Request().URL.Path)
+ })
+ }
go gameHubs.Run()