Serve frontend SPA from Go binary #17
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
austin/vektor#17
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The Dockerfile builds the frontend into
web/distbut the Go binary never serves it. In production, everything should be served from the single binary.What needs to happen
Production serving:
Use
go:embedto embed theweb/distdirectory into the binary. Serve it on all routes that don't match/api/or/auth/. Add a fallback: any non-file request returnsindex.html(SPA client-side routing).Development proxy:
Add a Vite proxy config in
vite.config.tsso/apiand/authrequests forward tolocalhost:8659during development. This lets you runvite devand the Go server separately.Key files
cmd/vektor/main.goorinternal/api/server.go— embed and serve static filesweb/vite.config.ts— add dev proxy