Fix port conflict: separate Next.js (3001) from Go API (PORT)
- Next.js admin now runs on internal port 3001 - Go API uses Dokku's PORT environment variable (5000) - Updated admin proxy default to localhost:3001 - Added /_next/* static asset proxy route This fixes the "address already in use" error when deploying to Dokku where both services were trying to bind to port 3000. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -359,10 +359,11 @@ func SetupRoutes(router *gin.Engine, db *gorm.DB, cfg *config.Config, deps *Depe
|
||||
|
||||
// setupAdminProxy configures reverse proxy to the Next.js admin panel
|
||||
func setupAdminProxy(router *gin.Engine) {
|
||||
// Get admin panel URL from env, default to localhost:3000
|
||||
// Get admin panel URL from env, default to localhost:3001
|
||||
// Note: In production (Dokku), Next.js runs on internal port 3001
|
||||
adminURL := os.Getenv("ADMIN_PANEL_URL")
|
||||
if adminURL == "" {
|
||||
adminURL = "http://127.0.0.1:3000"
|
||||
adminURL = "http://127.0.0.1:3001"
|
||||
}
|
||||
|
||||
target, err := url.Parse(adminURL)
|
||||
@@ -381,4 +382,9 @@ func setupAdminProxy(router *gin.Engine) {
|
||||
router.Any("/admin", func(c *gin.Context) {
|
||||
c.Redirect(http.StatusMovedPermanently, "/admin/")
|
||||
})
|
||||
|
||||
// Proxy Next.js static assets
|
||||
router.Any("/_next/*filepath", func(c *gin.Context) {
|
||||
proxy.ServeHTTP(c.Writer, c.Request)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user