fix(server): fix route conflict by using /dist prefix for static assets
Previously, static assets were served from the root "/" and "/assets" routes, which caused conflicts with the "/api" route. Changed to serve all static assets under the "/dist" prefix to avoid route collisions.
This commit is contained in:
@@ -5,8 +5,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
"markdown-editor/internal/storage"
|
"markdown-editor/internal/storage"
|
||||||
"markdown-editor/internal/api"
|
"markdown-editor/internal/api"
|
||||||
@@ -95,9 +93,8 @@ func (s *Server) serveStaticAssets() {
|
|||||||
|
|
||||||
s.log.Infof("Serving static assets from: %s", assetPath)
|
s.log.Infof("Serving static assets from: %s", assetPath)
|
||||||
|
|
||||||
// Serve files from the dist directory
|
// Serve files from the dist directory - use /dist prefix to avoid conflicts with /api
|
||||||
s.router.Static("/", assetPath)
|
s.router.Static("/dist", assetPath)
|
||||||
s.router.Static("/assets", filepath.Join(assetPath, "assets"))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) Shutdown(ctx context.Context) error {
|
func (s *Server) Shutdown(ctx context.Context) error {
|
||||||
|
|||||||
Reference in New Issue
Block a user