Fix: Cloudflare miss cors header

This commit is contained in:
CareyWong 2020-05-28 21:51:07 +08:00
parent cdeac8fa50
commit ef1b2ef364

View File

@ -90,8 +90,9 @@ func main() {
longUrl := context.PostForm("longUrl") longUrl := context.PostForm("longUrl")
shortKey := context.PostForm("shortKey") shortKey := context.PostForm("shortKey")
if longUrl == "" { if longUrl == "" {
res.Code = 0
res.Message = "longUrl为空" res.Message = "longUrl为空"
context.JSON(400, *res) context.JSON(200, *res)
return return
} }
@ -106,8 +107,9 @@ func main() {
// 检测短链是否已存在 // 检测短链是否已存在
_exists, _ := redis.String(redisClient.Do("get", shortKey)) _exists, _ := redis.String(redisClient.Do("get", shortKey))
if _exists != "" && _exists != longUrl { if _exists != "" && _exists != longUrl {
res.Code = 0
res.Message = "短链接已存在请更换key" res.Message = "短链接已存在请更换key"
context.JSON(400, *res) context.JSON(200, *res)
return return
} }