NutzCN Logo
问答 重定向视图 url变成了http://127.0.0.1:8080/xxx/xxx/xx ?
发布于 2461天前 作者 ensean 2453 次浏览 复制 上一个帖子 下一个帖子
标签:

RT, 系统发布到了测试环境,使用如下代码的时,重定向后 浏览器的url变成了 http://127.0.0.1:8080/xxx/logout ... 这是啥情况。。。。整个项目都没搜到 http://127.0.0.1:8080 ....

@At
@Ok(">>:/login")
void logout() {
    if (operator) {
        authManager.setOnline(operator.userId, false)
    }

    request.session.invalidate()
}
8 回复

描述错误,
是在测试环境请求 test.company.com/xxx/logout, 浏览器被重定向到了 http://127.0.0.1:8080/xxx/login ,而不是 test.company.com/xxx/login

nginx吗? proxy_pass吗? 没写 proxy_set_header吗?

无自己配nginx, 裸tomcat, 前面挂了个腾讯云的负载均衡(目测是nginx实现)
非proxy_pass
没写proxy_set_header ...

腾讯云的负载均衡应该要配域名的吧?

这种情况一般是后端没有收到 Host头

是的,有配置域名。 看源码,像是就算指定 完整url “http://test.company.com/xxx/login” 也是没啥用的?
public void render(HttpServletRequest req, HttpServletResponse resp, Object obj)
throws Exception {

    String path = evalPath(req, obj);

    // Another site
    if (path.startsWith("http://") || path.startsWith("https://")) {}
    // Absolute path, add the context path for it
    else if (path.length() > 0 && path.charAt(0) == '/') {
        path = req.getContextPath() + path;
    }
    resp.sendRedirect(path); // 这个原生支持相对路径的,就不要再做无用功了
    resp.flushBuffer();
}

我有点晕了。。。。指定全路径应该可以的,我去试试。。。。请忽略上一条。。。

写全路径没问题,特来汇报。。。

添加回复
请先登陆
回到顶部