{"record":{"id":"c1bcf742981f6333","repo":"dromara/Sa-Token","slug":"code-30014","errorCode":"CODE_30014","errorMessage":"未指定 redirect 参数，也未配置 homeRoute 路由，无法完成重定向操作","messagePattern":"未指定 redirect 参数，也未配置 homeRoute 路由，无法完成重定向操作","errorType":"exception","errorClass":"SaSsoException","httpStatus":null,"severity":"warning","filePath":"sa-token-plugin/sa-token-sso/src/main/java/cn/dev33/satoken/sso/processor/SaSsoServerProcessor.java","lineNumber":129,"sourceCode":"\t\t// 情况1，显示登录视图\n\t\tif( ! stpLogic.isLogin()) {\n\t\t\treturn ssoServerTemplate.strategy.notLoginView.get();\n\t\t}\n\n\t\t// 情况2，开始跳转\n\t\tString mode = req.getParam(paramName.mode, SaSsoConsts.MODE_TICKET);\n\t\tString redirect = req.getParam(paramName.redirect);\n\t\tString client = req.getParam(paramName.client);\n\n\t\t// 构建最终重定向地址\n\t\tString redirectUrl = SaSugar.get(() -> {\n\n\t\t\t// 若 redirect 参数为空，说明用户并不是从 client 重定向来的，而是直接访问的 http://sso-server.com/sso/auth 地址\n\t\t\t// 此时需要跳转到配置的 homeRoute 路由上，\n\t\t\t// 若 homeRoute 也为空，则没有明确的跳转地址了，需要抛出异常\n\t\t\tif(SaFoxUtil.isEmpty(redirect)) {\n\t\t\t\tif(SaFoxUtil.isEmpty(cfg.getHomeRoute())) {\n\t\t\t\t\tthrow new SaSsoException(\"未指定 redirect 参数，也未配置 homeRoute 路由，无法完成重定向操作\").setCode(SaSsoErrorCode.CODE_30014);\n\t\t\t\t}\n\t\t\t\treturn cfg.getHomeRoute();\n\t\t\t}\n\n\t\t\t// 方式1：直接重定向回Client端 (mode=simple，一般是模式一)\n\t\t\tif(mode.equals(SaSsoConsts.MODE_SIMPLE)) {\n\t\t\t\tssoServerTemplate.checkRedirectUrl(client, redirect);\n\t\t\t\treturn redirect;\n\t\t\t} else {\n\t\t\t\t// 方式2：带着 ticket 参数重定向回Client端 (mode=ticket，一般是模式二、三)\n\n\t\t\t\t// 构建并跳转\n\t\t\t\tString _redirectUrl = ssoServerTemplate.buildRedirectUrl(client, redirect, stpLogic.getLoginId(), stpLogic.getTokenValue());\n\n\t\t\t\t// 构建成功，说明 redirect 地址合法，此时需要更新一下当前 token 有效期\n\t\t\t\tif(cfg.getAutoRenewTimeout()) {\n\t\t\t\t\tstpLogic.renewTimeout(stpLogic.getConfigOrGlobal().getTimeout());\n\t\t\t\t}","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/dromara/Sa-Token/blob/ac2c7f6e94a78573cf0bcb932dd8b04e68fad189/sa-token-plugin/sa-token-sso/src/main/java/cn/dev33/satoken/sso/processor/SaSsoServerProcessor.java#L111-L147","documentation":"Thrown on the sso-server when a user opens /sso/auth directly in the browser: the request has no redirect parameter and no homeRoute has been configured. With nowhere to send the user after login, the server cannot complete the flow and aborts.","triggerScenarios":"Browser navigates to http://sso-server.com/sso/auth without a redirect query parameter while sa-token.sso.server.home-route is unset; typically a user bookmarked the login endpoint or opened it manually instead of being redirected from a client.","commonSituations":"First-time setup where the SSO server login page URL is visited directly; load balancer health checks hitting /sso/auth; missing home-route in application.yml for a deployment that expects direct logins.","solutions":["Configure a fallback landing page on the server: sa-token.sso.server.home-route=/system/index (or sa-token.sso.home-route depending on version)","Enter the SSO flow through a client app so the redirect parameter is present, instead of opening /sso/auth directly"],"exampleFix":"# before (application.yml on sso-server)\nsa-token:\n  sso:\n    server: {}   # no home-route\n\n# after\nsa-token:\n  sso:\n    home-route: /system/index","handlingStrategy":"validation","validationCode":"String redirect = req.getParam(paramName.redirect);\nif(SaFoxUtil.isEmpty(redirect) && SaFoxUtil.isEmpty(cfg.getHomeRoute())) {\n    // render a friendly page instead of letting the auth endpoint throw\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always configure home-route on production SSO servers","Point bookmarks and health checks at a stable route, not /sso/auth"],"tags":["sa-token","sso","config","redirect"],"backgroundTag":null,"analyzedSha":"ac2c7f6e94a78573cf0bcb932dd8b04e68fad189","analyzedAt":"2026-08-14T14:36:10.271Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}