Skip to content

Commit

Permalink
🚀 feat: remove websocket proxy and update routing to serve static fil…
Browse files Browse the repository at this point in the history
…es, add robots.txt and PWA icons
  • Loading branch information
vaayne committed Dec 28, 2024
1 parent 95bffb6 commit 5866cb3
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 137 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ require (
github.com/golang-jwt/jwt/v5 v5.2.1
github.com/golang-migrate/migrate/v4 v4.17.1
github.com/google/uuid v1.6.0
github.com/gorilla/websocket v1.5.3
github.com/invopop/jsonschema v0.12.0
github.com/jackc/pgx/v5 v5.6.0
github.com/joho/godotenv v1.5.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,6 @@ github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/Oth
github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM=
github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c=
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
Expand Down
125 changes: 0 additions & 125 deletions internal/port/httpserver/route_proxy_to_vite.go

This file was deleted.

20 changes: 11 additions & 9 deletions internal/port/httpserver/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package httpserver

import (
"net/http"
"vibrain/internal/pkg/config"
"vibrain/internal/pkg/logger"
"vibrain/web"

Expand Down Expand Up @@ -49,12 +48,15 @@ func (s *Service) registerRouters() {
e.GET("/swagger/*", echoSwagger.WrapHandler)

// web pages
if config.Settings.DebugUI {
// proxy to vite server localhost:5173
logger.Default.Debug("Using vite server as frontend")
e.GET("/*", reactReverseProxy)
} else {
logger.Default.Debug("Using static files as frontend")
e.GET("/*", echo.WrapHandler(http.FileServer(web.StaticHttpFS)))
}
logger.Default.Debug("Using static files as frontend")
e.GET("/manifest.webmanifest", func(c echo.Context) error {
file, err := web.StaticHttpFS.Open("manifest.webmanifest")
if err != nil {
return err
}
defer file.Close()
c.Response().Header().Set("Content-Type", "application/manifest+json")
return c.Stream(http.StatusOK, "application/manifest+json", file)
})
e.GET("/*", echo.WrapHandler(http.FileServer(web.StaticHttpFS)))
}
2 changes: 2 additions & 0 deletions web/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
User-agent: *
Allow: /
12 changes: 12 additions & 0 deletions web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ export default defineConfig({
sizes: "512x512",
type: "image/png",
},
{
src: 'pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any'
},
{
src: 'maskable-icon-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'maskable'
}
],
},
}),
Expand Down

0 comments on commit 5866cb3

Please sign in to comment.