Skip to content

Commit

Permalink
add something
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-david-welch committed Aug 25, 2024
1 parent 0190a5c commit 6d19edf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/routes/mainRoutes.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ func InitRoutes(router *gin.Engine, database *sql.DB, secrets *lib.Secrets, s3Cl
c.Redirect(http.StatusMovedPermanently, "/")
})

// Redirect /api requests without a valid route to /api root
router.NoRoute(func(c *gin.Context) {
// Return 404 for non-existent API routes
if c.Request.URL.Path[:4] == "/api" {
c.JSON(http.StatusNotFound, gin.H{
"message": "API route not found",
})
return
}
// Handle other non-API requests (which should go to the frontend)
c.JSON(http.StatusNotFound, gin.H{
"message": "Page not found",
})
})

// Supplier Module Resources
InitParts(router, database, s3Client, adminMiddleware)
InitVideos(router, database, secrets, adminMiddleware)
Expand Down

0 comments on commit 6d19edf

Please sign in to comment.