Simplify development workflow and fix content editing conflicts
- Replace complex multi-server setup (live-server + API) with unified Go server
- Serve all sites at /sites/{site_id} endpoints, eliminating port conflicts
- Fix content-type middleware to serve proper MIME types for static files
- Prevent script injection duplication with future-proof CDN-compatible detection
- Remove auto page reload from enhance button to eliminate editing interruptions
- Enable seamless content editing workflow with manual enhancement control
Development now requires only 'just dev' instead of complex demo commands.
All sites immediately available at localhost:8080 without hot reload conflicts.
This commit is contained in:
13
cmd/serve.go
13
cmd/serve.go
@@ -144,6 +144,15 @@ func runServe(cmd *cobra.Command, args []string) {
|
||||
// Static library serving (for demo sites)
|
||||
router.HandleFunc("/insertr.js", contentHandler.ServeInsertrJS).Methods("GET")
|
||||
|
||||
// Static site serving - serve registered sites at /sites/{site_id}
|
||||
siteRouter := router.PathPrefix("/sites").Subrouter()
|
||||
for siteID, siteConfig := range siteManager.GetAllSites() {
|
||||
log.Printf("📁 Serving site %s from %s at /sites/%s/", siteID, siteConfig.Path, siteID)
|
||||
siteRouter.PathPrefix("/" + siteID + "/").Handler(
|
||||
http.StripPrefix("/sites/"+siteID+"/",
|
||||
http.FileServer(http.Dir(siteConfig.Path))))
|
||||
}
|
||||
|
||||
// Handle CORS preflight requests explicitly
|
||||
contentRouter.HandleFunc("/{id}", api.CORSPreflightHandler).Methods("OPTIONS")
|
||||
contentRouter.HandleFunc("", api.CORSPreflightHandler).Methods("OPTIONS")
|
||||
@@ -171,6 +180,10 @@ func runServe(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf(" PUT /api/content/{id}\n")
|
||||
fmt.Printf(" GET /api/content/{id}/versions?site_id={site}\n")
|
||||
fmt.Printf(" POST /api/content/{id}/rollback\n")
|
||||
fmt.Printf("🌐 Static sites:\n")
|
||||
for siteID, _ := range siteManager.GetAllSites() {
|
||||
fmt.Printf(" %s: http://localhost%s/sites/%s/\n", siteID, addr, siteID)
|
||||
}
|
||||
fmt.Printf("\n🔄 Press Ctrl+C to shutdown gracefully\n\n")
|
||||
|
||||
// Setup graceful shutdown
|
||||
|
||||
Reference in New Issue
Block a user