From ef1b2ef364e4bfb72cae975980d1b5847d18a392 Mon Sep 17 00:00:00 2001 From: CareyWong Date: Thu, 28 May 2020 21:51:07 +0800 Subject: [PATCH] Fix: Cloudflare miss cors header --- main.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 4958914..177e09a 100644 --- a/main.go +++ b/main.go @@ -90,8 +90,9 @@ func main() { longUrl := context.PostForm("longUrl") shortKey := context.PostForm("shortKey") if longUrl == "" { + res.Code = 0 res.Message = "longUrl为空" - context.JSON(400, *res) + context.JSON(200, *res) return } @@ -106,8 +107,9 @@ func main() { // 检测短链是否已存在 _exists, _ := redis.String(redisClient.Do("get", shortKey)) if _exists != "" && _exists != longUrl { + res.Code = 0 res.Message = "短链接已存在,请更换key" - context.JSON(400, *res) + context.JSON(200, *res) return }