添加removeTrailingSlash方法后, localhost:3000 访问被重定向多次到无法访问

1.其他路由可以正常访问;
2.我去掉removeTrailingSlash 方法后 localhsot:3000 访问正常

最佳答案

检查 localhost:3000// 的代码是否正确添加

if r.URL.Path != "/" {
    r.URL.Path = strings.TrimSuffix(r.URL.Path, "/")
}
2年前 评论
tonysteak (楼主) 2年前
讨论数量: 1

检查 localhost:3000// 的代码是否正确添加

if r.URL.Path != "/" {
    r.URL.Path = strings.TrimSuffix(r.URL.Path, "/")
}
2年前 评论
tonysteak (楼主) 2年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!