Added Desktop app deployment (#39)
Created a desktop app using Walis framework. This embeds the frontend and backend into one binary that shows itself on a desktop
This commit is contained in:
+31
-17
@@ -8,23 +8,37 @@ import (
|
||||
)
|
||||
|
||||
func SetupGin(r *gin.Engine) {
|
||||
// Build allowed origins list from configuration
|
||||
allowedOrigins := []string{
|
||||
config.Cfg.FrontendURL,
|
||||
"http://localhost:5173", // Development frontend
|
||||
"http://192.168.0.48:5173", // Development frontend
|
||||
"http://192.168.0.36:5173", // Development frontend
|
||||
"https://bamort.trokan.de", // Production frontend
|
||||
var corsConfig cors.Config
|
||||
|
||||
// Desktop: the Wails WebView origin varies by platform/version (wails.localhost,
|
||||
// localhost, null …). Since the server is local, allow all origins.
|
||||
if config.Cfg.Environment == "desktop" {
|
||||
corsConfig = cors.Config{
|
||||
AllowOriginFunc: func(_ string) bool { return true },
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"},
|
||||
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 12 * 3600,
|
||||
}
|
||||
} else {
|
||||
allowedOrigins := []string{
|
||||
config.Cfg.FrontendURL,
|
||||
"http://localhost:5173", // Development frontend
|
||||
"http://192.168.0.48:5173", // Development frontend
|
||||
"http://192.168.0.36:5173", // Development frontend
|
||||
"https://bamort.trokan.de", // Production frontend
|
||||
"http://wails.localhost", // Wails desktop WebView
|
||||
}
|
||||
corsConfig = cors.Config{
|
||||
AllowOrigins: allowedOrigins,
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"},
|
||||
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 12 * 3600,
|
||||
}
|
||||
}
|
||||
|
||||
// Add CORS middleware
|
||||
r.Use(cors.New(cors.Config{
|
||||
//AllowOrigins: []string{"http://localhost:3000"}, // Replace with your frontend's URL
|
||||
AllowOrigins: allowedOrigins,
|
||||
AllowMethods: []string{"GET", "POST", "PUT", "PATCH", "DELETE"},
|
||||
AllowHeaders: []string{"Origin", "Content-Type", "Authorization"},
|
||||
ExposeHeaders: []string{"Content-Length"},
|
||||
AllowCredentials: true,
|
||||
MaxAge: 12 * 3600, // Cache preflight for 12 hours
|
||||
}))
|
||||
r.Use(cors.New(corsConfig))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user