From bfe739e442f5e1465c5e22c5e0bd91da339ef37d Mon Sep 17 00:00:00 2001 From: heimoshuiyu Date: Tue, 22 Nov 2022 13:46:44 +0800 Subject: [PATCH] path --- db/db.go | 3 ++- main.go | 9 +++++++-- web/package.json | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/db/db.go b/db/db.go index cb70006..a0afb1b 100644 --- a/db/db.go +++ b/db/db.go @@ -55,7 +55,7 @@ var ( func init() { var err error - DB, err = sql.Open("postgres", "postgres://itsc@localhost:5432/itsc?sslmode=disable") + DB, err = sql.Open("postgres", os.Getenv("POSTGRES_CONNSTR")) if err != nil { log.Fatal(err) } @@ -63,6 +63,7 @@ func init() { if len(os.Args) > 1{ if os.Args[1] == "install" { install() + os.Exit(0) } } diff --git a/main.go b/main.go index 20fe740..0e16209 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,12 @@ var wsUpgrader = websocket.Upgrader{ func main() { r := gin.Default() - r.Use(func(c *gin.Context) { + group := r.Group("/") + + group.StaticFile("/", "./web/build/index.html") + group.Static("/web", "./web/build") + + group.Use(func(c *gin.Context) { c.Next() if len(c.Errors) > 0 { c.JSON(-1, gin.H{ @@ -56,7 +61,7 @@ func main() { } }) - api := r.Group("/api") + api := group.Group("/api") api.GET("/timetables", func(c *gin.Context) { timetables := make([]*db.Timetable, 0) diff --git a/web/package.json b/web/package.json index 83ac8b3..74fc307 100644 --- a/web/package.json +++ b/web/package.json @@ -2,6 +2,7 @@ "name": "web", "version": "0.1.0", "private": true, + "homepage": "/web", "dependencies": { "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5",